Wanted: slow regexes

MRAB python at mrabarnett.plus.com
Wed Dec 8 11:24:02 EST 2010


On 08/12/2010 12:42, Alexander Gattin wrote:
> Hello,
>
> On Mon, Dec 06, 2010 at 04:08:16AM +0000, MRAB wrote:
>> I'm looking for examples of regexes which are
>> slow (especially those which seem never to
>> finish) but whose results are known.
>
> does it have anything to do with
> http://swtch.com/~rsc/regexp/regexp1.html?
>
The new regex still uses backtracking.

Interestingly, that webpage says that:

     ("a" x 100000) =~ /^(ab?)*$/

caused Perl to segfault. I tried it and it didn't segfault, but it
didn't match either, although:

     ("a" x 10000) =~ /^(ab?)*$/

did match.

Neither the re nor regex modules had any problem with it!



More information about the Python-list mailing list