public static boolean checkNum(String number) { String rex = "^[1-9]\\d*(\\.\\d+)?$"; Pattern p = Pattern.compile(rex); Matcher m = p.matcher(number); return m.find(); }