Created
September 30, 2021 23:30
-
-
Save rmsj/876701da85bbba2f4748746d2154c22e to your computer and use it in GitHub Desktop.
[Go Upper or Lower Case] Determine is a string is in lower or upper case in golang #go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func IsUpper(s string) bool { | |
for _, r := range s { | |
if !unicode.IsUpper(r) && unicode.IsLetter(r) { | |
return false | |
} | |
} | |
return true | |
} | |
func IsLower(s string) bool { | |
for _, r := range s { | |
if !unicode.IsLower(r) && unicode.IsLetter(r) { | |
return false | |
} | |
} | |
return true | |
} | |
func isFirstCharUpperCase(word string) bool { | |
runes := []rune(word) | |
if !unicode.IsUpper(runes[0]) || !unicode.IsLetter(runes[0]) { | |
return false | |
} | |
return true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment