I am using the following regular expression to confirm:
- 2 letters in upper-case
- 1 special character (in
!@#$&*
) - 2 numerals (
0
–9
) - 3 letters in lower-case
^(?=.*[A-Z].*[A-Z])(?=.*[!@#$&*])(?=.*[0-9].*[0-9])(?=.*[a-z].*[a-z].*[a-z]).{8}$
And it works fine for the flowing password: AdiNm!15
but I don’t understand why I had to write .{8}
. If I removed .{8}
it is not working. But I don’t like to add restriction of string length. Any Idea?