开发者

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+/', ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜