Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: regex alternation

by moritz (Cardinal)
on Sep 30, 2011 at 10:19 UTC ( #928736=note: print w/ replies, xml ) Need Help??

in reply to regex alternation

You can try something along these lines to avoid invoking the regex engine:

my $prefix = "in directory '/directory/tmp"; my $prefix_len = length $prefix; my $test3 = qr<^$prefix(/\..*'|')$>; for my $line (@test_array) { if (substr($line, 0, $prefix_len) eq $prefix && $line =~ $test3) { print "MATCHED\n"; } else { print "NO MATCH\n"; } }

But you need to Benchmark it to find out if it's actually faster with your data.

Comment on Re: regex alternation
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2015-11-27 00:51 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (710 votes), past polls