用于校验bigdecimal的正则表达式
class c1 {
public static void main(String[] args) {
BigDecimal bigDecimal = new BigDecimal("000.0000000000000000000000010000000");
System.out.println(bigDecimal.toString());//1.0000000E-24
System.out.println(bigDecimal.toPlainString());//0.0000000000000000000000010000000
System.out.println(bigDecimal.stripTrailingZeros().toString());//1E-24
System.out.println(bigDecimal.stripTrailingZeros().toPlainString());//0.000000000000000000000001
// 32位 其中小数点8位
String ss = "-?[1-9]\\d{0,23}(\\.\\d{1,8})?$|-?0(\\.\\d{1,8})?$";
// 井号是结束的意思 问号表示出现0次或者一次
Pattern compile = Pattern.compile(ss);
Matcher matcher = compile.matcher("0.112");//true
Matcher matcher2 = compile.matcher("-1.112");//true
Matcher matcher3 = compile.matcher("0.112");//true
Matcher matcher4 = compile.matcher("10.112");//true
Matcher matcher5 = compile.matcher("1.1121.112");//false
Matcher matcher6 = compile.matcher("111111111111111111111111.11111111");//true
Matcher matcher7 = compile.matcher("0");//true
Matcher matcher8 = compile.matcher("0.0");//true
Matcher matcher9 = compile.matcher("000.9");//false
System.out.println(matcher.matches());
System.out.println(matcher2.matches());
System.out.println(matcher3.matches());
System.out.println(matcher4.matches());
System.out.println(matcher5.matches());
System.out.println(matcher6.matches());
System.out.println(matcher7.matches());
System.out.println(matcher8.matches());
System.out.println(matcher9.matches());
}
}