title: Regex for a Complex Password
body: <p>I've got this Regex as a data annotation on a password field in a C# .NET MVC project.</p>
  
  <pre><code>[RegularExpression("(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[*+\\/|!\"£$%^&amp;*()#[\\]@~'?&gt;&lt;,.=-_]).{6,}", ErrorMessage = "Password must be between 6 and 20 characters and contain one uppercase letter, one lowercase letter, one digit and one special character.")]
  </code></pre>
  
  <p>I want to make the following passwords invalid:-</p>
  
  <ul>
  <li>Testing</li>
  <li>Testing1</li>
  <li>TesTinG123</li>
  </ul>
  
  <p>The following would be valid:-</p>
  
  <ul>
  <li>Testing1*</li>
  <li>T&amp;sting123*</li>
  <li>%F&amp;y5HD$S</li>
  </ul>
  
  <p>I would like a minimum of 6 characters, with at least one uppercase, one lower case, one digit and one special character. I hope the above regex would do it, but it lets <strong>Testing12</strong> and <strong>Tester12</strong> through as valid passwords.</p>
  
  <p>What can I change in the above to get what I am expecting? I assumed the above requires one uppercase, one lowercase, one numeric and one special character but obviously I am wrong?</p>
  
  <p>Thanks in advance!</p>