re.match question

Tony Sideris tonys111 at erols.com
Thu Oct 5 11:51:14 EDT 2000


"Thomas Svensson" <thomas.svensson at era.ericsson.se> wrote in message
news:39DC9F7C.67B71D52 at era.ericsson.se...
> Hello,
>
> I'm matching a list of strings. I want "xxxBar" to be a match but not
> "xxxFooBar", xxx can be anything. I've tried the following:
>
> re.match('^.*?(?!Foo)Bar$', word)
>
> re.match('^.*?(Foo){0}Bar$', word)
>
> But they all returns a match. What am I doing wrong?? I think this
> should be an easy thing to do.
>
>
> Thanks for any help,
> Thomas

re.match(r'^[^(?:Foo)]*Bar', 'xxxFooBar');

seems to be working for me. the above line fails, 'xxxBar' passes. may need
further tweeking...
-Tony






More information about the Python-list mailing list