检查正则表达式输入的一般模式:
String regexp = "\\d{2}\\D{3}"; //your regexp here
if (myInput_Input_a.matches(regexp)) {
//It's valid
}
上面的实际正则表达式假定您实际上意味着2个数字/数字(相同的东西)和3个非数字.相应调整.
正则表达式的变化:
"\\d{2}[a-zA-Z]{3}"; //makes sure the last three are constrained to a-z (allowing both upper and lower case)
"\\d{2}[a-z]{3}"; //makes sure the last three are constrained to a-z (allowing only lower case)
"\\d{2}[a-zåäöA-ZÅÄÖ]{3}"; //makes sure the last three are constrained to a-z and some other non US-ASCII characters (allowing both upper and lower case)
"\\d{2}\\p{IsAlphabetic}{3}" //last three can be any (unicode) alphabetic character not just in US-ASCII