fork download
  1. <?php
  2.  
  3. $re = "/'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(*SKIP)(?!)|-/";
  4. $strs = array("The 'big-yellow' house-is near the lake", "He doesn\'t like it because-he isn\'t from here.");
  5. foreach ($strs as $str) {
  6. $result = preg_split($re, $str);
  7. print_r($result);
  8. }
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Array
(
    [0] => The 'big-yellow' house
    [1] => is near the lake
)
Array
(
    [0] => He doesn\'t like it because
    [1] => he isn\'t from here.
)