<?xml version="1.0" encoding="windows-1252"?>
<node id="38223" title="RE: Regex optimizations" created="2000-10-24 21:13:50" updated="2005-07-19 14:08:39">
<type id="11">
note</type>
<author id="13201">
dchetlin</author>
<data>
<field name="doctext">
This is a good question. The answer is that the REx engine does &lt;strong&gt;not&lt;/strong&gt; optimize &lt;code&gt;\d{2}&lt;/code&gt; into &lt;code&gt;\d\d&lt;/code&gt;.

&lt;p&gt;Here's how to check:

&lt;p&gt;&lt;code&gt;
[~] $ 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'&lt;/code&gt;

&lt;p&gt;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.

&lt;p&gt;-dlc</field>
<field name="root_node">
38175</field>
<field name="parent_node">
38175</field>
</data>
</node>
