in reply to Re: Regex, capturing variables vs. speed
in thread Regex, capturing variables vs. speed
A particular drain on your combined regex is the ".*" (dot-star) you use to join the interesting ones.
I wouldn't automatically point fingers at the .* even though, as you say, .*? would probably be better for him. The issue is how his use of .* is combined with his use of .*? when what he really means is \S*. He'd probably see a significant speedup even if switching to \S* was his only change, but incorporating your suggestion makes sense as well.
So, I'd rewrite
my ($chr,$prot,$panel) = /(chr.*?)\s.*urn:lsid:(.*?)\s.*panel:(.*?):/i;as
(Note that changing the last .*? to [^:]* is a good idea too even if the efficiency gain isn't much.my ($chr, $prot, $panel) = /(chr\S*)\s.*?urn:lsid(\S*)\s.*?panel:([^:] +*):/i;
Update: Well, reading further down the thread, it seems robin beat me to it.
-sauoq "My two cents aren't worth a dime.";
|
|---|