isNumber更改为判断所有数字类型(含整数,浮点数,负数.)

This commit is contained in:
mazhicheng 2019-08-27 17:37:09 +08:00
parent 66202b153d
commit 6bfb8925a0
1 changed files with 3 additions and 18 deletions

View File

@ -157,8 +157,9 @@ public class V {
* @param str
* @return true Or false
*/
public static boolean isNumeric(String str){
return S.isNumeric(str);
public static boolean isNumber(String str){
String regex = "^(-?[1-9]\\d*\\.?\\d*)|(-?0\\.\\d*[1-9])|(-?[0])|(-?[0]\\.\\d*)$";
return str.matches(regex);
}
/**
@ -189,22 +190,6 @@ public class V {
return valid;
}
/**
* 判断是否为整型数字
* @param str
* @return
*/
public static boolean isNumber(String str) {
try{
S.isNumeric(str);
Integer.parseInt(str);
return true;
}
catch(Exception ex){
return false;
}
}
/**
* 是否boolean值范围
*/