Re: [pcre-dev] is this a BUG in PCRE 7.0 ?

Top Page
Delete this message
Author: Magnus Holmgren
Date:  
To: pcre-dev
Subject: Re: [pcre-dev] is this a BUG in PCRE 7.0 ?
On Monday 11 June 2007 07:10, Rain Chen wrote:
> $str = "repeater id='loopt' dataSrc=subject colums=2";
> preg_match_all("/(['\"])((.*(\\\\\\1)*)*)\\1/sU",$str,$str_instead);


A simpler solution might be

preg_match_all("/(['\"])((?:\\\\\\1|.)*)\\1/sU",$str,$str_instead);

(opening ' or ", then a sequence of (backslash followed by the same type of
quote, if possible, otherwise any single character), then a closing quote)

or

preg_match_all("/(['\"])(.*)(?<!\\\\)\\1/sU",$str,$str_instead);

(opening ' or ", then any string (as short as possible, due to the U flag),
then a matching ' or " that is not preceded by a backslash)

-- 
Magnus Holmgren        holmgren@???
                       (No Cc of list mail needed, thanks)


"Exim is better at being younger, whereas sendmail is better for
Scrabble (50 point bonus for clearing your rack)" -- Dave Evans