title: Understanding Regular Expression for Number Range
body: <p>I'm trying to build up some regular expressions to validate some textbox controls.  I have done some research and testing but cannot get this one working.  Examples of what i am trying to create regular expressions for are as follows:  </p>
  
  <ol>
  <li>Range 0-45, 0 decimal places  </li>
  <li>Range 0-20, 2 decimal places  </li>
  <li>Range 16-65, 0 decimal places  </li>
  <li>Range 0-99, 2 decimal places  </li>
  <li>Range 0-1500000, 0 decimal places  </li>
  <li>Range 0-200, 1 decimal place</li>
  </ol>
  
  <p>For 1 and 5 respectively, I have used  </p>
  
  <pre><code>([0-9]|[0-9]\d|45)$  
  ([0-9]|[0-9]\d|1500000)$  
  </code></pre>
  
  <p>The first one I am having problems for is an age range of 16-65 (inclusive), where I want no decimal places.  After a post on here (<a href="https://stackoverflow.com/questions/4093458/regular-expression-to-allow-numbers-between-90-0-and-90-0">Regular expression to allow numbers between -90.0 and +90.0</a>) I thought I could use the logic and get it sussed, but can't!  </p>
  
  <p>The expression I got to was:  </p>
  
  <pre><code>(\d|([1-6][6-4]))|65  
  </code></pre>
  
  <p>Can someone please tell me where I'm misunderstanding this! And any help with the other examples above would be gratefuly received.  </p>