Newbie question on Re module

Andrew McGregor andrew at indranet.co.nz
Sat Jan 4 06:01:32 EST 2003


[^(binaries)] is a single character that is not one of '(', 'b' etc.

You probably don't want to use an RE at all in Python; just use something 
like:

if str.index('binaries') == -1:
  # then str did not contain the word.

although:

rgx = re.compile('binaries')
if not rgx.match(str):
  # then str did also not match

does the same trick, just probably much slower.

--On Saturday, January 04, 2003 02:24:19 -0800 Jørgen Cederberg 
<jorgencederberg at hotmail.com> wrote:

> Josh <mlsj at earthlink.net> wrote in message
> news:<Xns92F5826AE2F65jslmAAearthlinknet at 130.133.1.4>...
>> 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:)
>>
>> Josh
>
> Hi Josh,
>
> not exactly an answer, but another link
> (http://db.cs.helsinki.fi/~hendry/python/). It is a playground area,
> where you can enter some input and a regular expression, and then see
> the results. Somewhat faster than using the interactive shell.
>
> Regards
> Jorgen
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>







More information about the Python-list mailing list