paatrick

Regex

Jan 27th, 2021
585
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $searchTerm = "coding";
  2.  
  3. if(preg_match("/\b$searchTerm\b/i", "Coding Dojo is the best!")) {
  4.   echo "Match found.<br/>";
  5. } else {
  6.   echo "No match found.<br/>";
  7. }
  8.  
  9. if(preg_match("/\b$searchTerm\b/i", "Decoding encryptions is just one of my many sexy hobbies.")) {
  10.   echo "Match found.<br/>";
  11. } else {
  12.   echo "No match found.<br/>";
  13. }
RAW Paste Data