fix:更新指标完成状态
This commit is contained in:
36
common/src/main/java/com/sdm/common/utils/CommonUtils.java
Normal file
36
common/src/main/java/com/sdm/common/utils/CommonUtils.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.sdm.common.utils;
|
||||
|
||||
public class CommonUtils {
|
||||
|
||||
/**
|
||||
* 检查字符串是否为有效的数字格式
|
||||
*/
|
||||
public static boolean isValidNumberFormat(String str) {
|
||||
if (str == null || str.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 支持:
|
||||
// 1. 整数:123, -123, +123
|
||||
// 2. 小数:123.45, .45, 123.
|
||||
// 3. 科学计数法:1.23e10, 1.23E-10
|
||||
// 4. 排除:空字符串、纯空格、多个小数点、非法字符
|
||||
|
||||
// 去除首尾空格
|
||||
str = str.trim();
|
||||
|
||||
// 检查是否为空
|
||||
if (str.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查是否只包含数字、小数点、正负号、e/E
|
||||
if (!str.matches("^[+-]?[\\d.eE]+$")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 更精确的正则表达式
|
||||
return str.matches("^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][+-]?\\d+)?$");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user