比如匹配不包含 ab 的字符串,使用 ^((?!ab)[\s\S])*$。
^((?!ab)[\s\S])*$
参考:正则表达式匹配不包含某些字符串的技巧、How to delete all comment lines in IDEA?