Regular expression for not-group
chris.lasher at gmail.com
Thu Jun 15 23:11:39 CEST 2006
Is it possible to write a regular expression such that a "match" is
found provided the string does not match a group in the regex? Let me
give a concrete example.
Suppose I want to find a match to any filename that does not end in
.py, (ignoring the obvious use of the .endswith('.py') string method).
I tried the things that were obvious to me, none of which worked.
The last one deceived me at first because it will match "spam.spam",
but not "spam.parrot". I'm a bit stumped at this point. If this can be
done with a regular expression, I'd love to know how, and even if it
can't be, that would be very helpful to know, too.
Many thanks in advance,
More information about the Python-list