public static boolean isNumeric(String str) {
if (null == str || "".equals(str)) {
return false;
}
String regx = "[+-]*\\d+\\.?\\d*[Ee]*[+-]*\\d+";
Pattern pattern = Pattern.compile(regx);
boolean isNumber = pattern.matcher(str).matches();
if (isNumber) {
return isNumber;
}
regx = "^[-\\+]?[.\\d]*$";
pattern = Pattern.compile(regx);
return pattern.matcher(str).matches();
}
————————————————
版权声明:本文为CSDN博主「iSelenium」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/xiaoguanyusb/article/details/88078417