String reg_money = "\d+(\.\d{1,2})?";// 金额正则,可以没有小数,小数最多不超过两位 Pattern pattern = Pattern.compile(reg_money); Matcher matcher = pattern.matcher("5566.21"); boolean ismatch = matcher.matches(); System.out.println(ismatch);
String reg_money = "\d+(\.\d{1,2})?";// 金额正则,可以没有小数,小数最多不超过两位 Pattern pattern = Pattern.compile(reg_money); Matcher matcher = pattern.matcher("5566.21"); boolean ismatch = matcher.matches(); System.out.println(ismatch);