判断是几位正小数
程序员文章站
2022-07-15 09:35:04
...
package test;
public class PointDemo {
public static void main(String[] args) {
String s = "^[0-9]+(\\.[0-9]{1,2})?$";
if ("3.02".matches(s)) {
System.out.println("符合一位或者两位小数");
}
}
}