fork download
  1. <?php
  2. $s = "'abc', 'def', 'ghf\\\\', 'jkl\'f'";
  3. echo "$s\n";
  4. if (preg_match_all("~'.*?(?<!(?:(?<!\\\\)\\\\))'~", $s, $arr))
  5. var_dump($arr[0]);
  6. ?>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
'abc', 'def', 'ghf\\', 'jkl\'f'
array(4) {
  [0]=>
  string(5) "'abc'"
  [1]=>
  string(5) "'def'"
  [2]=>
  string(7) "'ghf\\'"
  [3]=>
  string(8) "'jkl\'f'"
}