Regex to validate password strength -
my password strength criteria below :
- 8 characters length
- 2 letters in upper case
- 1 special character
(!@#$&*)
- 2 numerals
(0-9)
- 3 letters in lower case
can please give me regex same. conditions must met password .
you can these checks using positive ahead assertions:
^(?=.*[a-z].*[a-z])(?=.*[!@#$&*])(?=.*[0-9].*[0-9])(?=.*[a-z].*[a-z].*[a-z]).{8}$
explanation:
^ start anchor (?=.*[a-z].*[a-z]) ensure string has 2 uppercase letters. (?=.*[!@#$&*]) ensure string has 1 special case letter. (?=.*[0-9].*[0-9]) ensure string has 2 digits. (?=.*[a-z].*[a-z].*[a-z]) ensure string has 3 lowercase letters. .{8} ensure string of length 8. $ end anchor.
Comments
Post a Comment