fork download
  1. <?php
  2.  
  3. $haystack1 = "(Job: NAS-Inkrementell) Operation succeeded. MyNAS-2 reports duty.";
  4.  
  5. $needle1 = "Operation succeeded";
  6. echo preg_match_all('@(?<![\w-])' . preg_quote($needle1,'@') . '(?![\w-])@is', $haystack1, $matches1) ."\n";
  7.  
  8. $needle2 = "Operation succeeded.";
  9. echo preg_match_all('@(?<![\w-])' . preg_quote($needle2,'@') . '(?![\w-])@is', $haystack1, $matches2) ."\n";
  10.  
  11. $needle3 = "MyNAS";
  12. echo preg_match_all('@(?<![\w-])' . preg_quote($needle3,'@') . '(?![\w-])@is', $haystack1, $matches3) ."\n";
  13.  
  14. $needle4 = "MyNAS-2";
  15. echo preg_match_all('@(?<![\w-])' . preg_quote($needle4,'@') . '(?![\w-])@is', $haystack1, $matches4) ."\n";
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
1
1
0
1