note
hv
<p><i>The proof for the (x?|y) case follows immediately from regex union being commutative.</i></p>
<p>Regexp union is not commutative when one of the alternates is a leading substring of another: then order becomes important - <code>(E|x)</code> will always match <code>E</code> in preference to <code>x</code>.</p>
<p>It is the presence of the outer anchors in the original pattern that disambiguates and thus makes it commutative.</p>
<p>Hugo</p>
406643
406746