一、规则
补充
[a-ZA-Z]{2,}
:至少两个字母
例子
/* 匹配一个数字 */
String regex = "\\d";
String input = "1";
System.out.println(input.matches(regex));
// true
/* 匹配至少一个数字 */
String regex = "\\d+";
String input1 = "1";
System.out.println(input1.matches(regex));
// true
String input2 = "12";
System.out.println(input2.matches(regex));
// true
/* 匹配恰好两个字母 */
String regex = "[a-zA-Z]{2}";
String input = "aB";
System.out.println(input.matches(regex));
// true
/* 匹配至少两个字母 */
String regex = "[a-zA-Z]{2,}";
String input1 = "aB";
System.out.println(input1.matches(regex));
// true
String input2 = "aBcD";
System.out.println(input2.matches(regex));
// true