title: How to match the exact number of digits with regular expression in Javascript
body: <p>In Javascript, what I have done is the following:</p>
  
  <p><code>var matched = searched.match(/\d{7}/)</code></p>
  
  <p>It works great if <code>searched</code> is <code>1234567</code> or <code>XYZ1234567</code>. Both return <code>1234567</code>, which is good. <code>123</code> and <code>XYZ123</code> return null, which is expected.</p>
  
  <p>But one condition fails when <code>searched</code> is <code>12345678</code> or <code>XYZ12345678</code>. I would like both to return null because I look for an exact 7 digit match. They both return <code>2345678</code> instead.</p>
  
  <p><code>/\d{7}$/</code> does not work either.</p>
  
  <p>Can someone please advise?</p>
  
  <p>Thank you</p>