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'" } 

live demo: http://ideone.com/y80gas


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -