Check If the Rune is a Lowercase Letter or not in Golang
Rune is a superset of ASCII or it is an alias of int32. It holds all the characters available in the world’s writing system, including accents and other diacritical marks, control codes like tab and carriage return, and assigns each one a standard number. This standard number is known as a Unicode code point or rune in the Go language.
You are allowed to check the given rune is a lower case letter or not with the help of IsLower() function. This function returns true if the given rune is a lower case letter, or return false if the given rune is not a lower case letter. This function is defined under Unicode package, so for accessing this method you need to import the Unicode package in your program.
Syntax:
func IsLower(r rune) bool
The return type of this function is boolean. Let us discuss this concept with the help of given examples:
Example 1:
// Go program to illustrate how to check // the given rune is a lowercase letter // or not package main import ( "fmt" "unicode") // Main function func main() { // Creating rune rune_1 := 'g' rune_2 := 'e' rune_3 := 'E' rune_4 := 'k' rune_5 := 'S' // Checking the given rune is // a lower case letter or not // Using IsLower() function res_1 := unicode.IsLower(rune_1) res_2 := unicode.IsLower(rune_2) res_3 := unicode.IsLower(rune_3) res_4 := unicode.IsLower(rune_4) res_5 := unicode.IsLower(rune_5) // Displaying results fmt.Println(res_1) fmt.Println(res_2) fmt.Println(res_3) fmt.Println(res_4) fmt.Println(res_5) } |
Output:
true true false true false
Example 2:
// Go program to illustrate how to check // the given rune is a lowercase letter // or not package main import ( "fmt" "unicode") // Main function func main() { // Creating a slice of rune val := []rune{'g', 'E', 'e', 'K', 's'} // Checking each element of the given slice // of the rune is a lowercase letter // Using IsLower() function for i := 0; i < len(val); i++ { if unicode.IsLower(val[i]) == true { fmt.Printf("\n%c is a lower case letter", val[i]) } else { fmt.Printf("\n%c is not a lower case letter", val[i]) } } } |
Output:
g is a lower case letter E is not a lower case letter e is a lower case letter K is not a lower case letter s is a lower case letter
Recommended Posts:
- Check If the Rune is a Letter or not in Golang
- Check If the Rune is an Uppercase Letter or not in Golang
- How to Map a Rune to Lowercase in Golang?
- How to check the specified rune in Golang String?
- Check If the Rune is a Decimal Digit or not in Golang
- Check If the Rune is a Space Character or not in Golang
- Check If the Rune is a Symbolic Character or not in Golang
- Check If the Rune is a Unicode Punctuation Character or not in Golang
- Rune in Golang
- How to Map a Rune to Uppercase in Golang?
- How to Map a Rune to the Specified Case in Golang?
- How to Map a Rune to Title Case in Golang?
- Golang | How to find the index of rune in the string?
- How to convert a slice of bytes in lowercase in Golang?
- Check if the given slice is sorted in Golang
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


