//判断是否单双号,S单号,D双号
public static String checkCarLicense(String carLicense) {
for (int i = 0; i < carLicense.length(); i++) {
String lastnum=carLicense.substring(carLicense.length()-(i+1),carLicense.length()-i);
System.out.println(lastnum);
boolean isnum=isNum(lastnum);//判断是不是数字
if(isnum) {
//是数字,判断单双
int temp = Integer.valueOf(lastnum);
if(temp==0){
int a=0;
}
if(temp%2!=0){
//单数
return "S";
}else{
return "D";
}
}
}
//全是字母,基本不可能
return null;
}
public static boolean isNum(String str){
Pattern pattern = Pattern.compile("[0-9]*");
Matcher isNum = pattern.matcher(str);
if( !isNum.matches() ){
return false;
}
return true;
}