Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Regular expression match specific words


Globetrotter - 7:13 am on Jul 7, 2011 (gmt 0)


I'm looking for a regular expression that matches specific words in a string. I've tried a lot of options but none of them seem to work.

An oversimplified version which sort of works is

preg_match('/(ko|ao|an)/i',$output)


I would like to match the words "ko" or "ao" anywhere in a string followed by a space. Besided this match i would also match the word "'an" . If any of those two conditions is true it should return true.

At this time it sort of works but it sometimes finds a match when it shouldn't (for example if the word "cacao" is in the string it will match while it should only match on "ao some other word").


Thread source:: http://www.webmasterworld.com/php/4336203.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com