regexp ambiguity - luxembourg/muxcode-clm GitHub Wiki

REGEXP AMBIGUITY (continued)

For example, (ab|a)b*c' could match abc' in one of two ways. The first choice is between ab' and a'; since ab' is earlier, and does lead to a successful overall match, it is chosen. Since the b' is already spoken for, the `b*' must match its last possibility-the empty string-since it must respect the earlier choice.

In the particular case where no |'s are present and there is only one ', +', or ?', the net effect is that the longest possible match will be chosen. So ab*', presented with xabbbby', will match abbbb'. Note that if ab' is tried against xabyabbbz', it will match ab' just after `x', due to the begins-earliest rule. (In effect, the decision on where to start the match is the first choice to be made, hence subsequent choices must respect it even if this leads them to less-preferred alternatives.)

help regexp ambiguity2' for more }

⚠️ **GitHub.com Fallback** ⚠️