fork(1) download
  1. <?php
  2.  
  3. $re = "/(?s)'(?:[^'\\\\]|\\\\.)*'|\"(?:[^\"\\\\]|\\\\.)*\"/";
  4. $str = "\"string 'c' \\\" string \\\" \" and ' string \"ste\" \\' '";
  5. preg_match_all($re, $str, $matches);
  6. print_r($matches);
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] => "string 'c' \" string \" "
            [1] => ' string "ste" \' '
        )

)