title: generate a regexp from a numeric range
body: <p>I'd like to generate a (series of) regexp(s) from a numeric range.</p>
  
  <p>Example:</p>
  
  <pre><code>1013 - 4044 =&gt; 
  
  regexp                      matches
  ---------------------------------------
  101[3-9]                    1013 - 1019
  10[2-9][0-9]                1020 - 1099
  11[0-9][0-9]                1100 - 1199
  [23][0-9][0-9][0-9]         2000 - 3999
  40[0-3][0-9]                4000 - 4039
  404[0-4]                    4040 - 4044
  </code></pre>
  
  <p>what is the simplest algorithm? </p>
  
  <p>What is the easiest way to reverse it (i.e. given the regexps, looking for the ranges)?</p>
  
  <p>Would be nice to see solutions in java, clojure, perl...</p>
  
  <p>Thanks!</p>