<?php$str = '$str = "this is an \\" example of some input"; $but = "this is \\\\\\" another example\\" of input"; $and = "and here be one more\\\\"';echo $str . "\n";preg_match_all('~("(?:\\\\.|[^"])+?")~',$str,$match);print_r($match);/*Output:$str = "this is an \" example of some input"; $but = "this is \\\" another example\" of input"; $and = "and here be one more\\"Array( [0] => Array ( [0] => "this is an \" example of some input" [1] => "this is \\\" another example\" of input" [2] => "and here be one more\\" ) [1] => Array ( [0] => "this is an \" example of some input" [1] => "this is \\\" another example\" of input" [2] => "and here be one more\\" ))*/?>