I'm not surprised that a look-behing assertion takes longer than something like (?:\A|\n), especially by this small of a margin. What wouldn't make sense to me would be that /^.../m would be 15x slower than either of the regexes I proposed unless I was missing some feature of ^ that isn't captured by my proposals.
Perhaps ^ needs to be re-implemented as using the regex operations used to implement either of my proposals (since look-behind assertions weren't available when the ^ code was written and so it might use something much worse and your testing seems to show that it does).
- tye
In reply to Re^8: Surprisingly poor regex performance (apples)
by tye
in thread Surprisingly poor regex performance
by sgifford
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |