Password Validation in Java using Regular Expression

Regex Validation

This example shows how to validate a Password string in Java using regular expression with Regex Pattern and Matcher validation.

Password Regular Expression Pattern:

((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,20})

Whole combination is means, 6 to 20 characters string with at least one digit, one upper case letter, one lower case letter and one special symbol (“@#$%”). This regular expression pattern is very useful to implement a strong and complex password.

Share This Post On: