|
@@ -2183,14 +2183,13 @@ func DealDateTimeZero(t time.Time, format string) (timeStr string) {
|
|
|
// @return bool
|
|
|
// @return string
|
|
|
func IsPercentage(input string) (bool, string) {
|
|
|
- percentagePattern := `^(\d{1,2}(\.\d{1,2})?)%$`
|
|
|
+ percentagePattern := `^-?(\d{1,2}(\.\d{1,2})?)%$`
|
|
|
match, _ := regexp.MatchString(percentagePattern, input)
|
|
|
|
|
|
if match {
|
|
|
- // 提取百分比值
|
|
|
re := regexp.MustCompile(percentagePattern)
|
|
|
match := re.FindStringSubmatch(input)
|
|
|
- return true, match[1]
|
|
|
+ return true, match[1] // 返回第一个捕获组的内容,即整个负数百分比数值
|
|
|
}
|
|
|
|
|
|
return false, ""
|