代码:
String regex = "^(?!([a-zA-Z]+|\\d+)$)[a-zA-Z\\d]{6,20}$"; String a = "a11111111a"; boolean matches = a.matches(regex); System.out.println(matches);