判断字符串是否是数字

Posted fulucky

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了判断字符串是否是数字相关的知识,希望对你有一定的参考价值。

public class IsString {
    public static boolean isNum(String str){
        return str.matches("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$");
    }
    @Test
    public void test(){
        String str = "12344.33";
        System.out.println(IsString.isNum(str));
    }
}

  


以上是关于判断字符串是否是数字的主要内容,如果未能解决你的问题,请参考以下文章