Skip to content

Commit

Permalink
若可选字符是过滤完后为空,尝试只过滤第一个
Browse files Browse the repository at this point in the history
  • Loading branch information
fengqi committed Mar 27, 2024
1 parent 2d65c2b commit 9228201
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion utils/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,19 @@ func FilterTmpSuffix(name string) string {
}

// FilterOptionals 过滤掉可选的字符: 被中括号[]包围的
// 若是过滤完后为空,可能直接使用[]分段,尝试只过滤第一个
func FilterOptionals(name string) string {
return optionsMatch.ReplaceAllString(name, "")
clear := optionsMatch.ReplaceAllString(name, "")
if clear != "" {
return clear
}

find := optionsMatch.FindStringSubmatch(name)
if len(find) == 2 {
clear = strings.Replace(name, find[0], "", 1)
}

return clear
}

// CoverChsNumber 中文数字替换为阿拉伯数字
Expand Down

0 comments on commit 9228201

Please sign in to comment.