note
Zaxo
<p>If alternation worked in quantifiers, you'd want to put the eight first. The regex engine may be greedy, but it's also hasty. As soon as it matches an alternate it forgets about the remaining ones. Anything that would match the eight has already matched the four.</p>
<p>Translating to the intended regex,
<code>
$_ = "abc" x 4;
$re_short = qr/([0-9a-f]{4}|[0-9a-f]{8})/;
$re_long = qr/([0-9a-f]{8}|[0-9a-f]{4})/;
print $1, $/ if /$re_short/;
print $1, $/ if /$re_long/;
__END__
abca
abcabcab
</code></p>
<div class="pmsig"><div class="pmsig-82147">
<p>After Compline,<br/>Zaxo</p>
</div></div>
554443
554507