java and the other day and night and the rest and I'm still waiting for you
代码如下,亲测可用:
如有帮助请在我的回答上点个【采纳】
public static void main(String[] args) {
String s="^[A-Z]{5}|[A-Za-z0-9]{10}$";
String pwd="asdasd123A";
System.out.println(pwd.matches(s));
}
正则表达式做不到吧。你可以自己写一个方法
大致思路可以是:
将字符串转成字符数组,遍历计算大写和数字的个数,最后在判断数量
建议还是代码写吧,代码写简单点
public boolean isValidate(String str){
int length = str.length();
if(length < 10){
return false;
}
return length - str.replaceAll("[A-Z]","").length() >= 5;
}