Files
nysoure/server/utils/string.go
2025-09-08 21:59:55 +08:00

22 lines
317 B
Go

package utils
import (
"regexp"
"unicode"
)
func RemoveSpaces(s string) string {
reg := regexp.MustCompile(`\s+`)
return reg.ReplaceAllString(s, " ")
}
func OnlyPunctuation(s string) bool {
for _, r := range s {
if unicode.IsPunct(r) || unicode.IsSpace(r) {
continue
}
return false
}
return true
}