1 //金額驗證 2 public static boolean isNumber(String str){ 3 Pattern pattern=Pattern.compile("^(([1-9]{1}\\d*)|([0]{1}))(\\.(\\d){0,2})?$"); // 判斷小數點后2位的數字的正則表達式 4 Matcher match=pattern.matcher(str); 5 if(match.matches()==false){ 6 return false; 7 }else{ 8 return true; 9 } 10 }