Python RegExp

David Chipping davidchipping at gmail.com
Tue Mar 22 19:04:21 EST 2005


Jeff,

Thanks very much for that, I didn't even consider the option of it
finishing, considering I'm using a much slower machine it was running
for over 2 minutes when I just killed it! I think I get the rest now.

Cheers again,

-David


On Tue, 22 Mar 2005 17:52:22 -0600, Jeff Epler <jepler at unpythonic.net> wrote:
> On my machine the program finishes in 30 seconds. (it's a 1.5GHz machine)
> If the 'parm' group is removed, or if the buffer is shortened, the time
> is reduced considerably.
> 
> There are "pathological cases" for regular expressions which can take
> quite a long time.  In the case of your expression, it's happening for
> the group 'parm'.  I think, but don't know, that each time a candidate
> for 'parm' is found, the following '#' (or maybe the second '<'?) is not
> found, and it backtracks to try to match 'parm' in a different way,
> which involves considering many different combinations (basically, each
> 'name=' could be the start of a new instance of the first parenthsized
> subgroup of <parm>, or it could be part of the character class that
> includes [a-zA-Z=])
> 
> You may wish to consider using other approaches for parsing this text
> than regular expressions.
> 
> Jeff
> 
> 
>



More information about the Python-list mailing list