/**
* 正则表达式规则:-号出现0或者1次,0-9出现多次,小数点出现0或者1次,0-9出现多次
* @param str
* @return
*/
public static boolean isNumeric(String str) {
if (str != null && !str.isEmpty()) {
Pattern pattern = Pattern.compile("-?[0-9]*.?[0-9]*");
Matcher isNum = pattern.matcher(str);
if (isNum.matches()) {
return true;
}
}
return false;
}
网友评论