String regExp = "^[1-9][0-9]*(\\.[0-9]{1,"+n+"})?$"; //n为小数位数 Pattern p = Pattern.compile(regExp); Matcher m = p.matcher(str); return m.matches();
String regExp = "^[1-9][0-9]*(\\.[0-9]{1,"+n+"})?$"; //n为小数位数 Pattern p = Pattern.compile(regExp); Matcher m = p.matcher(str); return m.matches();