Next | Regular Expression Mastery | 30 |
/a+?(a|b)/
aaab
We reached END, so the match succeeds; it found the aa part of aaab
This time the non-greedy match was more efficient
But that's because it was lucky -- it happened to find a shorter match
When shorter matches exist, non-greedy may find them quickly
But if not, they are slower than their greedy counterparts.
Next | Copyright © 2002 M. J. Dominus |