开发者

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

开发者 https://www.devze.com 2023-01-10 20:57 出处:网络
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开发者_如何学JAVAA

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

精彩评论

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