java2db

How to validate the password by using regular expression in java



It is good to use regular expression to validate the password , rather than using validation functions . Regular expression is very easy and simple to modify .

 

Conditions to validate the password

(?=.*[A-Z])………:    At least one capital alphabet .

(?=.*[a-z])………:    At least one small alphabet .

(?=.*[\\d])……….:    At least one number.

(?=.*[@$#%])..:    At least one special character in @$#%.

(?!.*\\s)………. :    Not contain blank space .

.{6,17}……………:    Length between 6 to 17 characters.

 

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

 

Example to validate the password :

Execution Result:

validate the password Returns true if the password satisfied all validations , false otherwise.

validate the password change {6,17} values  to set password maximum and minimum length .

validate the password So these are the basic and common conditions to validate the password .




Related Posts :
How to validate email address by using regular expression in java
   [will not be published]



^ <