Created
July 6, 2014 08:17
-
-
Save digvijaybhakuni/4a76283513683aed6212 to your computer and use it in GitHub Desktop.
Validate password with regular expression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
/** | |
* Give true is all condition matches, otherwise false. | |
* @param String | |
* @return boolean | |
*/ | |
private boolean validatePassword(String password){ | |
Pattern pattern = Pattern.compile("((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,20})"); | |
Matcher matcher = pattern.matcher(password); | |
return matcher.matches(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment