checking a string against multiple patterns

Jonathan Gardner jgardner.jonathangardner.net at gmail.com
Tue Dec 18 14:27:28 EST 2007


On Dec 18, 4:41 am, tomasz <tmkm... at googlemail.com> wrote:
> Is there an alternative to it? Am I missing something? Python doesn't
> have special variables $1, $2 (right?) so you must assign the result
> of a match to a variable, to be able to access the groups.
>
> I'd appreciate any hints.
>

Don't use regexes for something as simple as this. Try find().

Most of the time I use regexes in perl (90%+) I am doing something
that can be done much better using the string methods and some simple
operations. Plus, it turns out to be faster than perl usually.



More information about the Python-list mailing list