81,092
社区成员
发帖
与我相关
我的任务
分享
String[] input = { "CC1233121", "cC12", "CCC", "aa12345678",
"ac87654321", "a1b2c4", "zz", "12345678" };
for (String str : input) {
System.out.println(str.matches("([a-zA-Z])\\1\\d{1,8}"));
}
true
false
false
true
false
false
false
false
String regex = "(\\w)\\1\\d{1,8}"
input.matches("([a-z]{2}|[A-Z]{2})\\d{0,8}");