fork(6) download
  1. <?php
  2.  
  3. $string = 'This is a test, Stackoverflow. 2014 Cecili0n';
  4.  
  5. if(preg_match("~(This)(?:.*?(Stackoverflow)|.*?)~i",$string,$match))
  6. print_r($match);
  7.  
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
Array
(
    [0] => This is a test, Stackoverflow
    [1] => This
    [2] => Stackoverflow
)