I want to create an expression for password as below:
Regex for passwords that must contain 8 characters, start with 2 lower or uppercase letters, contain one special character *
and a 5-digit number.
E.g.: az*12345
- It must be start with 2 characters;
- Contain only single
*
; - End with 5 digits.
I have tried it with this pattern:
(?=(.*[^a-zA-Z]){2})(?=.*[*]{1})(?=(.*\d){5}).{8}$
However, it yields almost the same results as a regex above. It starts with any character but I want the exact above mentioned pattern. I know I am close to it. Please suggest me what I should do.
^[a-zA-Z]{2}\*\d{5}$
be sufficient then? – Paul.*
. That means any character zero or more times. – Nick