public static boolean isCarNo(String carNo){
if (carNo.length() >= 7 && carNo.length() <= 8){
Pattern p = Pattern.compile("^([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[a-zA-Z](([ABCDF]((?![IO])[a-zA-Z0-9](?![IO]))[0-9]{4})|([0-9]{5}[ABCDF]))|[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1})$");
Matcher m = p.matcher(carNo);
if (!m.matches()){
return false;
}
return true;
}else{
return false;
}
}
原文连接:https://blog.csdn.net/u011010220/article/details/109509484