1 Star 0 Fork 0

menuiis / gkit

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
is.go 838 Bytes
一键复制 编辑 原始数据 按行查看 历史
SongZhibin97 提交于 2022-05-19 11:54 . feat:stringx
package stringx
import (
"unicode"
)
// IsAlpha checks if the string contains only unicode letters.
func IsAlpha(s string) bool {
if s == "" {
return false
}
for _, v := range s {
if !unicode.IsLetter(v) {
return false
}
}
return true
}
// IsAlphanumeric checks if the string contains only Unicode letters or digits.
func IsAlphanumeric(s string) bool {
if s == "" {
return false
}
for _, v := range s {
if !isAlphanumeric(v) {
return false
}
}
return true
}
// IsNumeric Checks if the string contains only digits. A decimal point is not a digit and returns false.
func IsNumeric(s string) bool {
if s == "" {
return false
}
for _, v := range s {
if !unicode.IsDigit(v) {
return false
}
}
return true
}
func isAlphanumeric(v rune) bool {
return unicode.IsDigit(v) || unicode.IsLetter(v)
}
Go
1
https://gitee.com/menciis/gkit.git
git@gitee.com:menciis/gkit.git
menciis
gkit
gkit
4f74120a101e

搜索帮助