I want a regular expression to check that:
A password contains at least eight characters, including at least one number and includes both lower and uppercase letter
I had some difficulty following the most popular answer for my circumstances. For example, my validation was failing with characters such as ;
or [
. I was not interested in white-listing my special characters, so I instead leveraged [^\w\s]
as a test - simply put - match non word characters (including numeric) and non white space characters. To summarize, here is what worked for me...
8
characters1
numeric character1
lowercase letter 1
uppercase letter 1
special character/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[^\w\s]).{8,}$/
JSFiddle Link - simple demo covering various cases