How to use a posix BRE
or a posix ERE
regex to match a line that doesn't contain 834
at any place in string?
I want to find grep '!<pattern>' file
which will be equal to grep -v '<pattern>' file
.
It is theoretical question on regex, that's why I don't want to use -v
flag.
I figured out how to list lines, that doesn't contain one character: ^[^8]*$
, for my case I also tried ^$|^.$|^..$|^([^8]..|.[^3].|..[^4])*$
, but that's not working as expected.
^([^8]*(8([^38]|3[^48])*)*)*$
(8(...)*)*
will match 8 then fall back to the[^8]*
when one of the[^3]|3[^4]
stuff matches. you have to something very like that - but expanded for all possibilities. regex is math - its why*
0 is a place-holder. negation is perfectly valid regex - you should not try to avoid doing it.