1.判斷一個值是不是純數字
String strpurchaseOrderCode="";
strpurchaseOrderCode.matches("[0-9]+")
2.判斷最後一位是不是數字
Pattern pattern=Pattern.compile("[0-9]*");
//取出最後一位數
String strdata=strpurchaseOrderCode.substring(strpurchaseOrderCode.length()-1, strpurchaseOrderCode.length());
Matcher isNum=pattern.matcher(strdata);
if(isNum.matches()){
//是數字
Integer data=Integer.valueOf(strdata);
String newdata=String.valueOf(data+1);
System.out.println(newdata);
//将最後一位數字替換,原數字+1
String newStrpurchaseOrderCode= strpurchaseOrderCode.replace(strpurchaseOrderCode.charAt(strpurchaseOrderCode.length()-1)+"", newdata);
System.out.println(newStrpurchaseOrderCode);
result.put("purchaseOrderCode", newStrpurchaseOrderCode);
}