Complex password validation with regular expression

By | July 20, 2017

Our team had to build a password validation regular expression for a client that had the following requirements. Below is the expression for anyone that needs anything like this. Hopefully I safe someone some time.

^(?=.{16,})(?=.*[1-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[(!@#$%^&*()_+|~\- =\`{}[\]:”;'<>?,.\/, )])(?!.*(.)\1).+$

  • Length 16 characters
  • At least one number
  • At least one lowercase character
  • At least one uppercase character
  • At least one special character from the following set “(!@#$%^&*()_+|~\- =\`{}[\]:”;'<>?,.\/, )]”
  • No sequential repeating characters

Must say regular expressions are the devils work, no mere-mortal can look at it and comprehend.

Leave a Reply

Your email address will not be published. Required fields are marked *