title: Regex to match a username
body: <p>I am trying to create a <code>regex</code> to validate usernames which should match the following :</p>
  
  <ul>
  <li>Only one special char <code>(._-)</code> allowed and it must not be at the extremas of the string </li>
  <li>The first character cannot be a number</li>
  <li>All the other characters allowed are letters and numbers</li>
  <li>The total length should be between 3 and 20 chars</li>
  </ul>
  
  <p>This is for a HTML5 validation pattern, so sadly it must be one big regex.</p>
  
  <p>So far this is what I've got:</p>
  
  <pre><code>^(?=(?![0-9])[A-Za-z0-9]+[._-]?[A-Za-z0-9]+).{3,20}
  </code></pre>
  
  <p>But the positive lookahead can be repeated more than one time allowing to be more than one special character which is not what I wanted. And I don't know how to correct that.</p>