5

What is the python equivalent of grep -v?

view full story
linux-howto

http://unix.stackexchange.com – I like grep -v. I use it all the time. But I am also doing some text processing in python, and there is one crucial thing that I lack. Usually, I use grep -v to take extraneous stuff out of text. For instance, $grep -v [a-z] (confirms that I don't want those lines) $grep [a-z] > linesiwanted But how do I match the complement of a regex in Python? For instance, the complement of \w? (HowTos)