Is it possible to write a regexp rule in "one line" that says: neither A nor B.
For example:
String must contain NEITHER "foo" NOR "bar".
Why one line? Because the filtering tool I am using accepts only one line ... I have tried things like (.*foo.*){0}(.*bar.*){0}
without enough luck.
\n. Matches a newline character. \r. Matches a carriage return character.
Line breaks In pattern matching, the symbols “^” and “$” match the beginning and end of the full file, not the beginning and end of a line. If you want to indicate a line break when you construct your RegEx, use the sequence “\r\n”.
\\. matches the literal character . . the first backslash is interpreted as an escape character by the Emacs string reader, which combined with the second backslash, inserts a literal backslash character into the string being read. the regular expression engine receives the string \.
Basically (0+1)* mathes any sequence of ones and zeroes. So, in your example (0+1)*1(0+1)* should match any sequence that has 1. It would not match 000 , but it would match 010 , 1 , 111 etc. (0+1) means 0 OR 1.
^(?!.*(foo|bar)).*$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With