/**
* 判断字符串是否为数字
* 包括负数
* @param str
* @return
*/
public static boolean isNumerEX(String str) {
Pattern pattern = Pattern.compile("-?[0-9]+.?[0-9]+");
Pattern pattern1 = Pattern.compile("[0-9]*");
if (pattern.matcher(str).matches() || pattern1.matcher(str).matches()) {
return true;
} else {
return false;
}
* 判断字符串是否为数字
* 包括负数
* @param str
* @return
*/
public static boolean isNumerEX(String str) {
Pattern pattern = Pattern.compile("-?[0-9]+.?[0-9]+");
Pattern pattern1 = Pattern.compile("[0-9]*");
if (pattern.matcher(str).matches() || pattern1.matcher(str).matches()) {
return true;
} else {
return false;
}
}
/**
* 判断字符串是否为数字
*
* @param str
* @return
*/
public static boolean isNumeric(String str) {
Pattern pattern = Pattern.compile("[0-9]*");
return pattern.matcher(str).matches();
}