php - Another tricky preg_match -
Only one paragraph contains "stop word", it needs to be seen, stop words are in the array below.
I have the formula:
$ pattern_array = array ("beforehand", "min", "stir", "summer", "put", "beat "," Bowl "," pan "); Foreign currency ($ pattern_array $ as pattern) {If (preg_match ('/'. Pattern $. '' / I ', $ paragraph)) {$ stopwords = 1; }}
Which works quite well, but the word 'panko' is termed as a stop word for the term 'pan'.
So the reges will be something in which it has a place or a new line is up and the ending in the full term / space / comma / (other non-eligible objects).
How do I tell PHP other than this? As soon as a stop word is detected, to exit the loop?
Thanks guys, learning to slow down as I go!
Use \ b (preheat | minutes | stir | heat | Put | bowl | pan) \ b
In the same way as your regex, you only need a regex (no looping required), and claiming the \ b
word boundary , You ensure that only match the whole words.
Comments
Post a Comment