Workshop

Quiz

1: What regular expression function would you use to match a pattern in a string?
2: What regular expression syntax would you use to match the letter “b” at least once but not more than six times?
3: How would you specify a character range between “d” and “f?”
4: How would you negate the character range you defined in question 3?
5: What syntax would you use to match either any number or the word “tree?”
6: What regular expression function would you use to replace a matched pattern?
7: The regular expression
.*bc

will match greedily; that is, it will match “abc000000bc” rather than “abc.” How would you make the preceding regular expression match only the first instance of a pattern it finds?

8: What backslash character will ...

Get Sams Teach Yourself PHP in 24 Hours, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.