开发者

regular expression to match exactly two words and not one of the the two

I am wondering , how would i match the words "SAN JOSE" in a string "I love SAN JOSE but JOSE does not like it " so in essence i do not want the the word Jose to be matched but S开发者_如何学JAVAAN JOSE should be matched together.

any ideas . thanks


You don't need regular expressions in this case. You didn't specify a language, but most of them support basic string matching. Just search for 'san jose' in case-insensitive mode.


You need a look-ahead assertion:

/san (?=jose)/


You need to escape the space:
/SAN\ JOSE/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜