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

Góra strony
Delete this message
Autor: Magnus Holmgren
Data:  
Dla: pcre-dev
Temat: 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