Hope you're fine
I would like to have a regex that could give me a password including these specifications :
- numerics
- alphabets ( Uppercase and Lowercase )
- 8 words at least
thanks you in advance !
Hope you're fine
I would like to have a regex that could give me a password including these specifications :
thanks you in advance !
You can use the regular expression (?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})
to validate if...
(?=.{8,})
),(?=.*[A-Z])
),(?=.*[a-z])
) and(?=.*[0-9])
).The following function in JavaScript shows how you can use the regular expression to check if a password meets the requirements.You didn't mention what language you where using, but it should work in a other langauges (it worked in Python, Ruby, PHP, & Java).
function validate_password(password) {
let check = /(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})/;
if (password.match(check)) {
console.log("Your password is strong.");
} else {
console.log("Meh, not so much.");
}
}
validate_password("Password123"); // strong password
validate_password("OtherPassword"); // no numbers
validate_password("password123"); // no uppercase
validate_password("ToShort"); // to short
this website has more details on password strength checking.