PHP reg exp ignore word
Trying to get a reg exp in PHP to work, I need it to match only if it doesn't start with a certain word.
Ex. Our ignore word will be "dave"
bill.smith <--- match<br/>
dave.smith <--- ignore<br/>
clyde.hancock <--- match<br/>
My current code is a bit of 开发者_JAVA百科a mess, I'm not sure how to properly ignore with word boundaries (I hope I was on the right path??)
Anyways, any help is appreciated.
Thanks
You can use a (?!...)
negative lookahead assertion for that:
preg_match('/^(?!dave\b)\w+\.\w+/', ...
精彩评论