Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2018-01-17 18:39 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (203 votes). Check out past polls.