Regular Expression question

looping kadeko at gmail.com
Thu Oct 25 03:54:07 EDT 2007


On Oct 25, 9:25 am, Peter Otten <__pete... at web.de> wrote:
>
> You want a "negative lookahead assertion" then:
>

Now I feel dumb...
I've seen the (?!...) dozen times in the doc but never figure out that
it is what I'm looking for.

So this one is the winner:
s = re.search(r'create\s+or\s+replace\s+package\s+(?!body\s+)', txt,
re.IGNORECASE)

Thanks Peter and Marc.




More information about the Python-list mailing list