if (!Pattern.matches("^([0-9]{1,})$", str)) { if (!Pattern.matches("^([0-9]{1,}[.][0-9]*)$", str)) { return false; } else { return true; } } else { return true; }
正则表达式,同时匹配正整数与浮点数,包含0
于 2022-06-15 10:33:04 首次发布
if (!Pattern.matches("^([0-9]{1,})$", str)) { if (!Pattern.matches("^([0-9]{1,}[.][0-9]*)$", str)) { return false; } else { return true; } } else { return true; }