fork(1) download
  1. <?php
  2.  
  3. $haystack1 = "(Job: NAS-Inkrementell) Operation succeeded. MyNAS-2 reports duty. The Server SERVER-2012->Increment failed as well. In addition the machine TK-Lap-01- has failed.";
  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";
  16.  
  17. $needle5 = "SERVER-2012";
  18. echo preg_match_all('@(?<![\w-])' . preg_quote($needle5,'@') . '(?![\w-])@is', $haystack1, $matches5) ."\n";
  19.  
  20. $needle6 = "TK-Lap-01";
  21. echo preg_match_all('@(?<![\w-])' . preg_quote($needle6,'@') . '(?![\w-])@is', $haystack1, $matches6) ."\n";
  22.  
Success #stdin #stdout 0.02s 52480KB
stdin
Standard input is empty
stdout
1
1
0
1
0
0