How match a regex if it does not contain a particular word?

I want to write a regex in Python or JavaScript to match if the given string does not JUST contain the given word (eg "any").

For example :

any : does not match
AnY : does not match
anyday : match
any day : match
blabla : match


If you also need words other that starting with "any" you can use a negative lookahead

^(?!any$).*$

This will match anything besides "any".


不使用正则表达式可能更有效,这也适用:

def noAny(i):
    i = i.lower().replace('any', '')
    return len(i) > 0

像这样的东西:

/(any)(.+)/i
链接地址: http://www.djcxy.com/p/76704.html

上一篇: 一个永远不会被任何东西匹配的正则表达式

下一篇: 如果匹配正则表达式,如果它不包含特定的单词?