Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>According to <a href="http://code.activestate.com/recipes/534137/" rel="nofollow noreferrer">Generate a Regular Expression to Match an Arbitrary Numeric Range</a>, and after generating such a regex for your example at <a href="https://web.archive.org/web/20151029043426/http://utilitymill.com/utility/Regex_For_Range" rel="nofollow noreferrer">Regex_For_Range</a>:</p> <pre><code>\b0*(1[1-9][0-9]|[2-9][0-9]{2}|1[0-9]{3}|2[01][0-9]{2}|22[0-2][0-9]|223[0-4])\b </code></pre> <p>would do the trick.</p> <p>The process would be (still following that Regex generator):</p> <blockquote> <p>First, break into equal length ranges:</p> </blockquote> <pre><code>110 - 999 1000 - 2234 </code></pre> <blockquote> <p>Second, break into ranges that yield simple regexes:</p> </blockquote> <pre><code>110 - 199 200 - 999 1000 - 1999 2000 - 2199 2200 - 2229 2230 - 2234 </code></pre> <blockquote> <p>Turn each range into a regex:</p> </blockquote> <pre><code>1[1-9][0-9] [2-9][0-9]{2} 1[0-9]{3} 2[01][0-9]{2} 22[0-2][0-9] 223[0-4] </code></pre> <blockquote> <p>Collapse adjacent powers of 10: 1[1-9][0-9] [2-9][0-9]{2} 1[0-9]{3} 2[01][0-9]{2} 22[0-2][0-9] 223[0-4]</p> <p>Combining the regexes above yields:</p> </blockquote> <pre><code>0*(1[1-9][0-9]|[2-9][0-9]{2}|1[0-9]{3}|2[01][0-9]{2}|22[0-2][0-9]|223[0-4]) </code></pre> <blockquote> <p>Next we'll try factoring out common prefixes using a tree:<br> Parse into tree based on regex prefixes:</p> </blockquote> <pre><code>. 1 [1-9] [0-9] + [0-9]{3} + [2-9] [0-9]{2} + 2 [01] [0-9]{2} + 2 [0-2] [0-9] + 3 [0-4] </code></pre> <blockquote> <p>Turning the parse tree into a regex yields:</p> </blockquote> <pre><code>0*(1([1-9][0-9]|[0-9]{3})|[2-9][0-9]{2}|2([01][0-9]{2}|2([0-2][0-9]|3[0-4]))) </code></pre> <blockquote> <p>We choose the shorter one as our result.</p> </blockquote> <pre><code>\b0*(1[1-9][0-9]|[2-9][0-9]{2}|1[0-9]{3}|2[01][0-9]{2}|22[0-2][0-9]|223[0-4])\b </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload