标签: regex
我需要正则表达式,检查字符串是否包含foo且不包含bar 例如
foo
bar
foo - pass something only with foo - pass with foo and bar - fail without fu but bar - fail abracadabra - fail
答案 0 :(得分:0)
试试这个:^(?!.*(bar)).*foo.*$
^(?!.*(bar)).*foo.*$