I\'m trying to write a password validator.
How can I see if my supplied string contains at least 3 different character groups?
It\'s easy enough to check if
I am assuming that you will be using different regexes for different requirements. In that case, tell me if the following work for you:
var e = password.match(/.{8,}/); //At least 8 chars
var a = password.match(/[0-9]+/); //numeric
var b = password.match(/[A-Z]+/); //Capitals
var c = password.match(/[a-z]+/); //small letters
var d = password.match(/[!@#\$%&/=?_.,:;-\\]+/); //special chars
if (a + b + c + d > 2 && e) {// Success}
else {// Failure}