Tuesday, October 21, 2014

Regular expression example 3


 <?php  
      // type of regular expression  
      //posix style regular exrpession  
      //pcre style regular expression  
      $sentence = "I lob to have tea but some time I prefer coffee";  
      $regexp="love|lob|feelings";  
      // search the search the mentioned words in the sentence  
      if(ereg($regexp,$sentence))  
      {  
           echo "regular expression is true";  
      }  
      else  
      {  
           echo "regular expression is false";  
      }  
 ?>  

No comments:

Post a Comment