|
@@ -86,11 +86,6 @@ public final class StringUtils {
|
|
|
*/
|
|
|
public static final String LETTER_REGEX = "[a-zA-Z]+";
|
|
|
|
|
|
- /**
|
|
|
- * 整数正则表达式
|
|
|
- */
|
|
|
- public static final String INTEGER_REGEX = "-?[0-9]+";
|
|
|
-
|
|
|
/**
|
|
|
* 逗号拆分分隔符
|
|
|
*/
|
|
@@ -124,7 +119,7 @@ public final class StringUtils {
|
|
|
/**
|
|
|
* 数字正则表达式
|
|
|
*/
|
|
|
- public static final String NUMBER_REGEX = "-?(\\.?[0-9]+|[0-9]+\\.?[0-9]+|[0-9]+\\.?)";
|
|
|
+ public static final String NUMBER_REGEX = "[\\+-]?(\\.?[0-9]+|[0-9]+\\.?[0-9]+|[0-9]+\\.?)";
|
|
|
|
|
|
/**
|
|
|
* URL正则表达式
|
|
@@ -432,7 +427,17 @@ public final class StringUtils {
|
|
|
* @return true/false
|
|
|
*/
|
|
|
public static <T extends CharSequence> boolean isInteger(T source) {
|
|
|
- return notEmpty(source) && getPattern(INTEGER_REGEX).matcher(source).matches();
|
|
|
+ if (isEmpty(source)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ char first = source.charAt(0);
|
|
|
+ int i = first == '+' || first == '-' ? 1 : 0;
|
|
|
+ for (int length = source.length(); i < length; i++) {
|
|
|
+ if (!Character.isDigit(source.charAt(i))) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|