Here’s a quick tip: if you do a simple
perl -Mre=debug -le'"some test data here" =~ /your regex here/'
on the command line, you will see a) how the regex engine compiles your pattern, including which optimisations it discovered to be applicable while compiling, and b) which steps it performs during actual matching, including which optimisations actually made a difference. (F.ex., seeing “Match rejected by optimizer” for input you want to reject is ideal, because it means the match failure was detected even before the engine was powered up.)
This is an invaluable aid in understanding the performance characteristics of different patterns, as you can see just what the engine is really doing.
Makeshifts last the longest.
In reply to Re: Regex, capturing variables vs. speed
by Aristotle
in thread Regex, capturing variables vs. speed
by albert
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |