// 判断字符串是否同时有字母和数字,且不指定以字母或数字开头
public static boolean isLetterAndDigital(String content) {
String regEx ="([a-z]+\\d+:+)";
Pattern pattern1 = Pattern.compile(regEx);
Matcher matcher1 = pattern1.matcher(content);
boolean flag1 =false;
while (matcher1.find()) {
System.out.println(matcher1.group(0));
flag1 =true;
break;
}
System.out.println(flag1);
String regEx2 ="(\\d+[a-z]+:+)";
Pattern pattern2 = Pattern.compile(regEx2);
Matcher matcher2 = pattern2.matcher(content);
boolean flag2 =false;
while (matcher2.find()) {
System.out.println(matcher2.group(0));
flag2 =true;
break;
}
System.out.println(flag2);
return flag1 || flag2;
}
// 执行
public static void main(String[] args) {
String content ="aaaaf11:aaaaf11:aaaaf11:aaaaf11:";
System.out.println(isLetterAndDigital(content));
}