Regular Expression - Password Validation is not working
Posted
by Kesavan
on Stack Overflow
See other posts from Stack Overflow
or by Kesavan
Published on 2010-06-09T16:25:59Z
Indexed on
2010/06/09
16:32 UTC
Read the original article
Hit count: 222
regex
|input-validation
Hi,
I have to validate the password using regex. The password rule is like at least 1 uppercase and at least 2 numeric.
It works fine except if the character comes at the end of the string.
The regular expression which i am using is
"^(?=.*\d.{2})(?=.*[A-Z].{1})(?=.*[@#$%^&+=].{2}).{8,12}$"
Rules:
- minimum length = 8
- minimum uppercase = 1
- minimum numeric = 2
- minimum special character = 1
It works for Test123$$
, Test$123
, TEST123$s
, Test123$1
, Test12$3
but it fails if the character specified comes at the end of the string like Test123$
, Test$a12
, Test12aa@
, 123aa@@T
.
Please let me know if there is any fix for this.
© Stack Overflow or respective owner