[TriLUG] [hopefully] quickie help with a regex
wejii
wejii at bellsouth.net
Tue Aug 10 17:58:53 EDT 2010
This seems to work for ascii letters, digits, and whitespace -
preg_match_all('/\'[a-zA-Z0-9\s]*\'/', $input, $result);
Other characters like &, $, @, ... may be included if you want.
I am uncomfortable using the dot "." feature for several reasons. Here is one:
>From O'Reilly's "Regular Expression Cookbook"
"Dot abuse
The dot is the most abused regular expression feature. ‹\d\d. \d\d. \d\d› is not a good
way to match a date. It does match 05/16/08 just fine, but it also matches 99/99/99.
Worse, it matches 12345678."
I hope this is helpful.
Walt
More information about the TriLUG
mailing list