Tuesday, 15 May 2012

php - Where's the bug in my regex? -



php - Where's the bug in my regex? -

i trying build regex extract values of pseudo-xml-tags (enclodes in{} instead of <>) , doesn't work. have verified thing regexbuddy, favourite rx-tool captured quite correct, when using in php-code, not result. so, w/o farther ado, here's problem:

$match=array(); $ret=preg_match('\{lang\s*=\s*[\"\']*?(.*?)[\"\']*?\s*/\}',"{lang='de'/}xxxxlxlxlxl",$match);

why $match empty?

the pattern should be

/\{lang\s*=\s*[\"\']*?(.*?)[\"\']*?\s*\/\}/ ^ ^

php regex

No comments:

Post a Comment