develooper Front page | perl.perl5.porters | Postings from May 2004

slow regex?

Thread Next
From:
Dave Mitchell
Date:
May 24, 2004 16:17
Subject:
slow regex?
Message ID:
20040524232301.GA1866@iabyn.com
This regex takes 2.5 secs on my machine to fail to match (5.8.4 and
bleed):

    $_ = <<'EOF';
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
    EOF

    print "matched\n" if /.*?A.*?B+\s+X/s;

While I can see that it may need to backtrack 70x70 times, this still
seems quite slow. (This is a stripped-down version of a regex I wrote
for production code that basically  ground to a halt).

Is this is bug, or do I have unrealistic expectations?

Dave.

-- 
In England there is a special word which means the last sunshine
of the summer. That word is "spring".

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About