What regular expression function would you use to match a pattern in a string?
What regular expression syntax would you use to match the letter "b" at least once but not more than six times?
How would you specify a character range between "d" and "f?"
How would you negate the character range you defined in question 3?
What syntax would you use to match either any number or the word "tree?"
What regular expression function would you use to replace a matched pattern?
The regular expression
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?
What backslash character will match whitespace?
What function could you use to match every instance of a pattern in a string?
Which modifier would you use in a PCRE function to match a pattern independently of case?
You can use the preg_match() function to find a pattern in a string.
You can use braces containing the minimum and maximum instances (the bounds) of a character to match:
You can specify a character range using square brackets:
You can negate a character range with the caret symbol:
You can match alternative branches with the pipe (|) character:
You can use the preg_replace() function to replace a matched pattern with a given alternative.
By adding a question mark to a quantifier, you can force the match to be nongreedy:
\s will match whitespace in a PCRE.
The preg_match_all() function will match every instance of a pattern in a string.
The /i modifier will make a PCRE function match independently of case.