I faced some problem while validating a password that will contain minimum 5 characters using regex.
I am using a very simple regex as below:
String PASSWORD_PATTERN_MIN_CHARS = "(?=.*[a-z|A-Z]{5,}).{8,}";
The regex says password must contains minimum 5 characters and minimum 8 chars will be passwrd length.
It is working fine for "aasaT124"
String. But fails for "aa12sa4T"
.
Clearly the difference is regex matches only if the characters are sequential.
The String for which validation fails also contains minimum 5 characters.