title: Creating a regex that accept first 4 digit prefix and 3 number after
body: <p>I need a regex that would validate first 4 digit set and then 3 digits. The first foure digits need to be identical. </p>
  
  <p>Acceptable entries should be for example: </p>
  
  <pre><code>7777989  
  8888767 
  </code></pre>
  
  <p>Invalid entries:</p>
  
  <pre><code>7778888
  7777abc
  8989123
  </code></pre>
  
  <p>Now my problem is that in my code iam creating the regexes based on class names. for example something like this</p>
  
  <pre><code>if (currentChar == 'n') regex += '[0-9]'; 
  else if (currentChar == 'd') regex += '^[0-9]+$';
  </code></pre>
  
  <p>in above code n and d is class name where n represents "any digit" and d represents "identical digits". So for the above example, the rule would be <code>ddddnnn</code>.</p>