title: Validate UK Driving license regex in javascript
body: <p>Is it possible to validate a UK driving license with the following rules?</p>
  
  <blockquote>
    <ul>
    <li>Digit 1–5: Letters A-Z or 9's</li>
    <li>Digit 6-11: Numbers 0-9</li>
    <li>Digit 12–13: Letters A-Z or 9's</li>
    <li>Digit 14: Number 0-9 </li>
    <li>Digit 15–16: Two letters A-Z</li>
    </ul>
  </blockquote>
  
  <p>So far I have the following but it is not working:</p>
  
  <pre><code>var regex = /^[A-Z0-9]{5}\d[0156]\d([0][1-9]|[12]\d|3[01])\d[A-Z0-9]{3}[A-Z]{2}$/
  </code></pre>
  
  <p>The following should pass:</p>
  
  <pre><code>  [
      'FARME100165AB5EW',
      'MAR99740614BC2TL',
      'MARTI740614A92TL',
      'MARTI740614992TL',
      '99999740614992TL'
    ].forEach(drivingLicenceNumber =&gt; regex.test(drivingLicenceNumber)
  </code></pre>
  
  <p>Only the first element of the array passes.</p>
  
  <p>And the following should fail</p>
  
  <pre><code>  [
      '1FARM382940AZ9AZ',
      'F2ARM382940AZ9AZ',
      'FA3RM382940AZ9AZ',
      'FAR4M382940AZ9AZ',
      'FARM5382940AZ9AZ'
    ].forEach(drivingLicenceNumber =&gt; !regx.text(drivingLicenceNumber)
  </code></pre>