This commit is contained in:
xh
2025-07-24 02:05:23 +08:00
parent 41ff5171d6
commit 717438e97f
9 changed files with 160 additions and 63 deletions

View File

@@ -2,6 +2,7 @@ package util
import (
"bytes"
"regexp"
"strings"
"unicode"
@@ -49,3 +50,9 @@ func (su stringUtil) ToUpperCamelCase(s string) string {
}
return strings.Join(words, "")
}
// 检查字符串只能包含字母、数字和下划线
func (su stringUtil) CheckSafeString(s string) bool {
reg := regexp.MustCompile(`^[a-zA-Z0-9_]+$`)
return !reg.MatchString(s)
}