Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: regex for negating a sequence

by aquarium (Curate)
on Oct 03, 2006 at 19:21 UTC ( #576204=note: print w/replies, xml ) Need Help??


in reply to regex for negating a sequence

might be faster to just loop (5 times) through the next two characters in the string and test for equality. lookahead/lookbehind assertions are rather expensive if the string being matched is long
$matched = undef; for($index=0,$index<11;$index+=2) { if(substr($test_string;$index,2) eq "ab") { $matched = 1; last; } }
untested code
the hardest line to type correctly is: stty erase ^H

Replies are listed 'Best First'.
Re^2: regex for negating a sequence (lookaheads and lookbehinds are now fast)
by grinder (Bishop) on Oct 04, 2006 at 10:53 UTC
    lookahead/lookbehind assertions are rather expensive if the string being matched is long

    demerphq might be too shy to toot his own horn, but a couple of weeks he landed an awesome patch to the development version of Perl that teaches the optimiser to look inside those assertions and use the information to improve the matching strategy used. Which equates to some massive speedups in some cases, perhaps the cases to which you were alluding.

    Let's just hope that Perl 5.10 sees the light of day soon. There's lots of goodness in there waiting to be unleashed.

    • another intruder with the mooring in the heart of the Perl

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://576204]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2019-07-18 20:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?