Browse Source

Merge branch 'bug/4433_IsPercentage' into debug

Roc 10 months ago
parent
commit
4a644f25b8
1 changed files with 2 additions and 3 deletions
  1. 2 3
      utils/common.go

+ 2 - 3
utils/common.go

@@ -2090,14 +2090,13 @@ func GetColorMap() map[int]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, ""