Password Regex For Specific Requirements
I am to write a regex for following requirements At least one character At least one digit Length must be of 8 At least one special character(Can be any special character) First
Solution 1:
You can solve these with a combination of lookaheads:
(?=.*[a-zA-Z])
(?=.*\d)
.{8}
(?=.*[^\da-zA-Z])
The last one just requires a non-letter and non-digit which is probably by far the easiest way of specifying that you want a somewhat “special” character.
So in the end you have
^(?=.*[a-zA-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{8}$
Post a Comment for "Password Regex For Specific Requirements"