Regular expressions in python

Graeme Longman glongman at ilangua.com
Wed Jul 3 11:45:34 EDT 2002


Hi,

I'm using the python module re to search through strings of html text
but I have found that it is taking too long using the seach method.

I am looping though a list of regular expressions and I find that it
takes much longer when no match is found for the expression than it does
when a match is found. Is this normal ?

I have fixed the problem for now by using string.find() before searching
the text but was wondering if anyone had any ideas on a better
technique.

Is there something else I should be using ? I am using '.*' and
re.DOTALL in my expressions but that doesn't seem to be the problem.

Thanks for any help in advance.

Graeme






More information about the Python-list mailing list