in reply to Re^4: simple pattern match ?
in thread simple pattern match ?
Yes. The regex engine uses backtracking and marks its location whenever it has to make a decision. If the first decision doesn't work out, it backtracks to the last marked point and uses the next possible decision. The ? regex operator is such a decision point and I guess that basically, the two possibilities for a match are:
and[012345]\d
So in this case, it would not get a match when trying /[012345]\d/ against 5, so it backtracks, and tries /\d/, which works.\d
|
|---|