Newbie question on Re module

Peter Hansen peter at engcorp.com
Tue Dec 31 14:26:52 EST 2002


Josh wrote:
> 
> I am trying to strip out all binaries groups from a list of newsgroups.
> Basically I wanted to write a regular expression that would match all non
> binaries groups. But this does not seem to work:
> rgx=re.compile('[^(binaries)]'). My question is why not? How else would I
> write the regex? I am a newbie at Regexes so please be kind:)

You might want to read http://www.amk.ca/python/howto/regex/ and 
pay special attention to the section called "4.4 Other Assertions".
Specifically, the negative lookahead assertion, and the example of
matching filenames where the extension is not "bat".

-Peter



More information about the Python-list mailing list