Golang unicode.IsSpace() function example
package unicode
Golang unicode.IsSpace() function usage example. Useful when you want to determine if an input character/rune is a space.
package main
import (
"fmt"
"unicode"
)
func main() {
space := unicode.IsSpace(' ')
fmt.Println(" is a space ? : ", space)
digit := unicode.IsSpace('1')
fmt.Println("1 is a space ? : ", digit)
tab := unicode.IsSpace('\t')
fmt.Println("Tab is a space ? : ", tab)
newLine := unicode.IsSpace('\n')
fmt.Println("New line is a space ? : ", newLine)
}
Output :
is a space ? : true
1 is a space ? : false
Tab is a space ? : true
New line is a space ? : true
References :
'\t', '\n', '\v', '\f', '\r', ' ', U+0085 (NEL), U+00A0 (NBSP).
Other definitions of spacing characters are set by category Z and property PatternWhiteSpace.
Advertisement
Something interesting
Tutorials
+9.1k Golang : Handle sub domain with Gin
+21.6k Golang : Encrypt and decrypt data with TripleDES
+3.7k Golang : Switch Redis database redis.NewClient
+25.4k Golang : Convert long hexadecimal with strconv.ParseUint example
+20.3k Golang : Check if os.Stdin input data is piped or from terminal
+7.2k Golang : Check if one string(rune) is permutation of another string(rune)
+21.1k Golang : Sort and reverse sort a slice of strings
+4.9k Python : Find out the variable type and determine the type with simple test
+11.9k Golang : Convert decimal number(integer) to IPv4 address
+6.8k Unix/Linux : How to fix CentOS yum duplicate glibc or device-mapper-libs dependency error?
+22.9k Golang : Gorilla mux routing example
+6.9k How to let Facebook Login button redirect to a particular URL ?