title: Regular Expressions, Checking for a range of occurrences
body: <p>I have a phone number I want to match against a regular expression.
  The format of the phone number must match this:</p>
  
  <p>(123) 123-4567 x12345</p>
  
  <p>The extension is optional. Also the extension must contain 1-5 numbers.
  Below is a regular expression I wrote that works.</p>
  
  <pre><code>^\(\d{3}\) \d{3}-\d{4}( x\d\d?\d?\d?\d?)?$
  </code></pre>
  
  <p>I was wondering if there is a better way to check for the extension instead of</p>
  
  <pre><code>x\d\d?\d?\d?\d?
  </code></pre>
  
  <p>Can I say 1-5 occurrences of \d instead of the above some how ?</p>