Android 密码正则表达式验证
要求:
密码是包含 字母、数字、标点符号 组合8~16位的字符串;
1、密码中必须包含字母,大小写没有限制;
2、密码中必须包含数字;
3、密码中可包含标点符号,非必需 ;
// 密码正则验证
public boolean isPassword(String password){
String regex="^(?![0-9]+$)(?![a-zA-Z]+$)(?![a-zA-Z\\W]+$)(?![0-9\\W]+$)[0-9A-Za-z#%&*@,,。.??::;;!!+-=+-=]{8,16}$";
Pattern p= Pattern.compile(regex);
Matcher m=p.matcher(password);
boolean isMatch=m.matches();
Log.i("ForgetCipActivity", "isPassword: 是否密码正则匹配"+isMatch);
return isMatch;
}
经过项目测试可用, 正则表达式还有待优化
转载请注明出处