Sam's Blog entries for 22 April 2010
Anchoring Regexps
Date: Thursday, 22 April 2010, 15:14.
Categories: perl, ironman, regexp, craft, optimization, basic, tutorial.
A common mistake I find whenever I look at someone else's regexps, is a failure to anchor the regexp.
This is often, in my experience, the single biggest thing you can do to improve the performance of a regexp: it's one of those things you should learn to do in every regexp where applicable, which should be almost every regexp unless you're specifically looking for "something somewhere in the middle but I don't know where".
So, what is anchoring, and why does it have such a big impact?