fork download
  1. <?php
  2. $text = "'abc', 'def', 'ghf\'\\\', 'jkl\'f'";
  3. print("Input: ".$text."\n");
  4. preg_match_all("/'((?:(?<!\\\)\\\'|[^'])+)'/", $text, $match);
  5. print_r($match);
  6.  
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
Input: 'abc', 'def', 'ghf\'\\', 'jkl\'f'
Array
(
    [0] => Array
        (
            [0] => 'abc'
            [1] => 'def'
            [2] => 'ghf\'\\'
            [3] => 'jkl\'f'
        )

    [1] => Array
        (
            [0] => abc
            [1] => def
            [2] => ghf\'\\
            [3] => jkl\'f
        )

)