1 public class CarNumberUtil { 2 /* 3 *车牌号格式:汉字 + A-Z + 5位A-Z或0-9 4 *(只包括了普通车牌号,教练车和部分部队车等车牌号不包括在内) 5 */ 6 public static boolean isCarnumberNO(String carnumber) { 7 8 String carnumRegex = "[A-Z_a-z]{1}[A-Z_a-z_0-9]{5}"; 9 if (TextUtils.isEmpty(carnumber)) return false; 10 else return carnumber.matches(carnumRegex); 11 } 12 13 public static boolean isCar(String carnumber){ 14 String carnumRegex = "[\\u4E00-\\u9FA5][\\da-zA-Z]{6}$"; 15 // String carnumRegex="/^[\\u4e00-\\u9fa5]{1}[A-Z]{1}[A-Z_0-9]{5}$/"; 16 if (TextUtils.isEmpty(carnumber)) return false; 17 else return carnumber.matches(carnumRegex); 18 } 19 20 /* 21 车架号由数字和字母组成 22 */ 23 public static boolean isCarjao(String carnumber){ 24 Pattern idNumPattern = Pattern.compile("^[A-Za-z0-9]+$"); 25 //通过Pattern获得Matcher 26 Matcher idNumMatcher = idNumPattern.matcher(carnumber); 27 28 return idNumMatcher.matches(); 29 } 30 }
直接调用即可