Home >Backend Development >Golang >Golang determines whether a character is a letter
go languageYou can use the IsLetter method of the unicode package to determine whether a character is a letter.
func IsLetter(r rune) bool
IsLetter Reports whether the rune is a letter (category L).
// IsLetter 判断 r 是否为一个字母字符 (类别 L) // 汉字也是一个字母字符 func IsLetter(r rune) bool func main() { s := "Hello\n\t世界!" for _, r := range s { fmt.Printf("%c = %v\n", r, unicode.IsLetter(r)) } // Hello世界 = true }
For more golang knowledge, please pay attention to the golang tutorial column.
The above is the detailed content of Golang determines whether a character is a letter. For more information, please follow other related articles on the PHP Chinese website!