fork download
  1. <?php
  2.  
  3.  
  4. $string = "PHP is the website scripting @ language of choice.";
  5.  
  6. $find = "website scripting @";
  7. $find = preg_quote($find);
  8. if (preg_match('/\w$/u', $find)) { // Setting trailing word boundary
  9. $find .= '\\b';
  10. }
  11.  
  12. if (preg_match('/^\w/u', $find)) { // Setting leading word boundary
  13. $find = '\\b' . $find;
  14. }
  15.  
  16. if (preg_match("/" . $find . "/ui", $string)) {
  17. echo "A match was found.";
  18. } else {
  19. echo "A match was not found.";
  20. }
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
A match was found.