Regex for Password Must be contain at least 8 characters, least 1 number and both lower and uppercase letters and special characters

Posted by user2442653 on Stack Overflow See other posts from Stack Overflow or by user2442653
Published on 2013-10-26T09:42:10Z Indexed on 2013/10/26 9:53 UTC
Read the original article Hit count: 168

Filed under:
|
|

I want a regular expression to check that

Password Must be contain at least 8 characters, including at least 1 number and includes both lower and uppercase letters and special characters (e.g., #, ?, !)

Cannot be your old password or contain your username, "password", or "websitename"

And here is my validation expression which is for 8 characters including 1 uppercase letter, 1 lowercase letter, 1 number or special character.

(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$"

How I can write it for password must be 8 characters including 1 uppercase letter, 1 special character and alphanumeric characters?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about ASP.NET