验证密码正则表达式

/**
* 验证密码,必须要6位字符以上。且必要要有数字和英文,符号中的任意两种
* @param password
* @return
*/
@SuppressWarnings("unused")
private static boolean isPasswordInfo(String password){
Pattern pa=Pattern.compile("^(?![0-9]+$)(?![a-zA-Z]+$)(?!([^(0-9a-zA-Z)]|[\\(\\)])+$)([^(0-9a-zA-Z)]|[\\(\\)]|[a-zA-Z]|[0-9]){6,20}$");
return pa.matcher(password).matches();
}


/**
* 验证密码,且必要要有数字和英文,符号中的任意一种
* @param password
* @return
*/
private static boolean isPassword(String password){
Pattern pa=Pattern.compile("^[0-9a-zA-Z]{6,20}$");
return pa.matcher(password).matches();
}

你可能感兴趣的:(验证密码正则表达式)