Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正面临正则表达式的问题,并想为这些条件编写该工作:
如果字符串不是以 ++ 和 ** 开头,则匹配如下模式:
45 www.google.com =>匹配 **MO 12:45:08 =>不匹配 ++ 110413 =>不匹配
45 www.google.com =>匹配
**MO 12:45:08 =>不匹配
++ 110413 =>不匹配
有任何想法吗?
您可以使用负前瞻来检查:
^(?!\+\+|\*\*)
这通过使用负前瞻来匹配在字符串开头没有++OR的任何字符串**(?!...)
++
**
(?!...)
参考:http ://www.regular-expressions.info/lookaround.html