title: Regular Expression that matches a number with commas for every three digits
body: <p>It needs to match these</p>
  
  <ul>
  <li>'42'</li>
  <li>'1,234'</li>
  <li>'6,368,745'</li>
  </ul>
  
  <p>but not the following:</p>
  
  <ul>
  <li>'12,34,567' (which has only two digits between the commas)</li>
  <li>'1234' (which lacks commas)</li>
  </ul>
  
  <p>I been using site such as <a href="http://www.regexpal.com/" rel="nofollow">http://www.regexpal.com/</a> to test out expressions.</p>
  
  <p>I tried</p>
  
  <ul>
  <li><code>^\d{1,3}(,\d{3})*$</code></li>
  <li><code>(\d{1,3},)*(\d{1,3})$</code></li>
  <li><code>([0-9]{1,3},)*([0-9]{1,3})$</code></li>
  <li><code>[0-9]{1,3}((,[0-9]){1,3})*</code></li>
  </ul>
  
  <p>but it doesn't work.</p>
  
  <p>Could someone explain what's wrong with my attempts and an model answer?</p>