Prechádzať zdrojové kódy

Merge branch 'bug/2024-4-19_IsPercentage' into debug

Roc 1 rok pred
rodič
commit
0cc6723700
1 zmenil súbory, kde vykonal 2 pridanie a 3 odobranie
  1. 2 3
      utils/common.go

+ 2 - 3
utils/common.go

@@ -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, ""