Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re^2: Regexp string concat

by runrig (Abbot)
on Jun 14, 2004 at 22:33 UTC ( #366721=note: print w/replies, xml ) Need Help??

in reply to Re: Regexp string concat
in thread Regexp string concat

For a slight speed boost, use compiled regular expressions:
my $string = 'eichenbaumschule'; my @query = qw(baum ums eic chu le); @query = map { qr/($_)/i } @query; $string =~ s/$_/\U$1/g for @query;
(I get ~6000 iterations/sec this way vs. ~3000 your way).

Update: Just realized, this is only a factor if you do the same substitutions multiple times in the same program...if you're only doing this once per run, then you may as well do it delirium's way :-)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2016-10-24 15:53 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (309 votes). Check out past polls.