0

Looking for a regex to validate a password. Password requirements:

  1. MUST contain at least 8 character (12+ recommended).
  2. MUST contain at least one uppercase letter.
  3. MUST contain at least one lowercase letter.
  4. MUST contain at least one number.
  5. MUST contain at least one special character (!"#$%&'()*+,-./:;<=>?).
  6. MAY NOT contain more then two identical characters in a row.

So far I have all but the last one (6) "^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!”#$%&'()*+,-./:;<=>?]).{8,16}$". How can I test requirement six in the regex?

Using .NET Core 5 C#

Lee Taylor
  • 7,155
  • 14
  • 29
  • 44
dhamilton
  • 141
  • 4
  • 11
  • The suggested link was not an exact answer. But it did lead to the answer. This regex gives exactly what I needed: "^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[\!\”\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\\?])(?!.*(.)\1{2}).{8,16}$" – dhamilton Apr 29 '22 at 21:58

0 Answers0