Just another Perl shrine | |
PerlMonks |
Re: the case where regex seems to work slowerby Corion (Patriarch) |
on Jul 26, 2017 at 09:32 UTC ( [id://1196090]=note: print w/replies, xml ) | Need Help?? |
Most likely, the difference comes when one regex engine is backtracking to ultimately fail. I'm not sure what the exact problem description is, but maybe you can speed things up by making some match fails not greedy or atomic (or both). Maybe the following fails faster:
Or maybe the following replacement makes things fail faster, as it prevents backtracking over that group if it ever failed.:
(As a note, your second replacement has no /g flag while the Ruby code uses .gsub in both cases)
In Section
Seekers of Perl Wisdom
|
|