note
grinder
<blockquote><i></i></blockquote>
<p></p>
<code>perl -MRegexp::Assemble -le 'print Regexp::Assemble->new->add(0..100)->as_string'
</code>
<p>...produces...</p>
<code>(?:1(?:[123456789]|0?0)?|2\d?|3\d?|4\d?|5\d?|6\d?|7\d?|8\d?|9\d?|0)</code>
<p>This could be simplified by gathering the 2\d?, 3\d?... subpatterns and factoring them into [2-9]\d?, but that would be less efficient since character classes are slower, and in 5.10 this would bypass [demerphq]'s trie optimisation.</p>
<p>On the plus side, while it will examine all the 10 primary alternatives during a fail, it's failing on EXACT matches, which is fast.</p>
<p>This lesson was brought to you by Stupid Regexp Trick I Can Play.</p>
<div class="pmsig"><div class="pmsig-29008">
<p align="right"><font size="-2">• another intruder with the mooring in the heart of the Perl</font></p>
</div></div>
751125
751125