4 ms·
Needless to say, all of this only works if the regex engine satisfies certain assumptions, i.e., order of "evaluation" is guaranteed. In abstract semantics of
by ganafagol 5y ago
Needless to say, all of this only works if the regex engine satisfies certain assumptions, i.e., order of "evaluation" is guaranteed.
In abstract semantics of regular expressions, a|b and b|a are equivalent.
- BeeOnRope 5y agoIt doesn't rely on order of operations, at least in this example? "Tarzan" will match one character earlier than Tarzan as the sting is scanned, so it would be discarded even if you flipped the order of the alternation. This isn't true of examples where the good and bad marches can start at the same character.
- ganafagol 5y agoThat the input is matched position by position to alternative patterns and the first one is returned is another one of said assumptions.