php - Extract all strings values from code -
everyone. have problem , can't resolve it.
pattern: \'(.*?)\'
source string: 'abc', 'def', 'gh\'', 'ui'
i need [abc], [def], [gh\'], [ui]
but [abc], [def], [gh\], [, ] etc.
is possible? in advance
php code: using negative lookbehind
$s = "'abc', 'def', 'ghf\\\\', 'jkl\'f'"; echo "$s\n"; if (preg_match_all("~'.*?(?<!(?:(?<!\\\\)\\\\))'~", $s, $arr)) var_dump($arr[0]); outout:
array(4) { [0]=> string(5) "'abc'" [1]=> string(5) "'def'" [2]=> string(7) "'ghf\\'" [3]=> string(8) "'jkl\'f'" }
Comments
Post a Comment