前端之家收集整理的这篇文章主要介绍了
正则表达式验证密码(大小写字母、数字、特殊符号 四选三),
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
String patten = "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_]+$)(?![a-z0-9]+$)(?![a-z\\W_]+$)(?![0-9\\W_]+$)[a-zA-Z0-9\\W_]{8,}$";
String password1 = "fukang"; // false
String password2 = "Fukanggggg"; // false
String password3 = "fukang123"; // false
String password4 = "Fukang123"; // true
String password5 = "##Fuk%%"; // false
String password6 = "###fukang%%"; // false
String password7 = "66FFFFFFFFFF";// false
System.out.println(password1.matches(patten));
System.out.println(password2.matches(patten));
System.out.println(password3.matches(patten));
System.out.println(password4.matches(patten));
System.out.println(password5.matches(patten));
System.out.println(password6.matches(patten));
System.out.println(password7.matches(patten));
原文链接:https://www.f2er.com/regex/357937.html