[TriLUG] Subject: [hopefully] quickie help with a regex

Kevin Hunter hunteke at earlham.edu
Wed Aug 11 23:46:43 EDT 2010


At 11:46am -0500 Tue, 10 Aug 2010, wejii wrote:
> This is what I got -
>
>     preg_match_all('/\'.*\'/i', ' ', $result);

Consider using double quotes to enclose the entire string.  Then you do 
not need to escape the internal quotes, and the regex is that much 
easier to read (something you want to do because regexes are already so 
hard to read!):

preg_match_all( "/'.*'/i", ' ', $result);


> [sloppily allows matching entire line, but don't know how to
>  do otherwise]

Take a look at the script I wrote to the list on 08 Aug.  It solves an 
example of the internal quotes with "negative look behind assertions".

Kevin



More information about the TriLUG mailing list