This is a good question. The answer is that the REx engine does
not optimize
\d{2} into
\d\d.
Here's how to check:
[~] $ perl -Mre=debug -e'qr/\d{2}/'
Freeing REx: `,'
Compiling REx `\d{2}'
size 4 first at 3
1: CURLY {2,2}(4)
3: DIGIT(0)
4: END(0)
stclass `DIGIT' minlen 2
Freeing REx: `\d{2}'
[~] $ perl -Mre=debug -e'qr/\d\d/'
Freeing REx: `,'
Compiling REx `\d\d'
size 3 first at 1
1: DIGIT(2)
2: DIGIT(3)
3: END(0)
stclass `DIGIT' minlen 2
Freeing REx: `\d\d'
Why doesn't it? I don't know. But as the Benchmarks above have noted, I can't imagine that difference being notable enough to really worry about.
-dlc
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.