None None REGEXP

Is it possible to write a regexp rule in "one line" that says: neither A nor B.

For instance:

String must contain NEITHER "foo" NOR "bar".

Why one line? Since the filtering tool that I use takes only one line ... I have not tried things like (.*foo.*){0}(.*bar.*){0}.

+3
source share
1 answer
^(?!.*(foo|bar)).*$
+7
source

Source: https://habr.com/ru/post/1748324/


All Articles