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)); } }