当前位置:主页 > >

JAVA只保留数字和小数点的方法

时间:2019-11-18 23:57:43 | 栏目: | 点击:

在写程序的时候,有时候可能需要保留小数和位数,请看本文介绍的方法。

public static void main(String[] args) {
        String str1 ="入账 -666.00";
        String REGEX ="[^(0-9).]";
        System.out.println(Pattern.compile(REGEX).matcher(str1).replaceAll("").trim());
}

您可能感兴趣的文章:

相关文章