Best implementation for an isNumber(string) method

前端 未结 19 2606
感动是毒
感动是毒 2020-12-15 20:04

In my limited experience, I\'ve been on several projects that have had some sort of string utility class with methods to determine if a given string is a number. The idea h

19条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-15 20:21

     public static boolean isNumber(String str){
          return str.matches("[0-9]*\\.[0-9]+");
        }
    

    to check whether number (including float, integer) or not

提交回复
热议问题