Go Package unicode: Difference between revisions
Jump to navigation
Jump to search
Line 9: | Line 9: | ||
Also see: {{Internal|Go_Strings#Introspecting_Characters|Strings | Introspecting Charancters}} | Also see: {{Internal|Go_Strings#Introspecting_Characters|Strings | Introspecting Charancters}} | ||
====<tt>IsDigit()</tt>==== | ====<tt>IsDigit()</tt>==== | ||
<syntaxhighlight lang='go'> | |||
s := "A 10" | |||
rs := []rune(s) | |||
fmt.Printf("char: %c, is digit: %t\n", rs[0], unicode.IsDigit(rs[0])) | |||
fmt.Printf("char: %c, is digit: %t\n", rs[2], unicode.IsDigit(rs[2])) | |||
</syntaxhighlight> | |||
prints: | |||
<syntaxhighlight lang='text'> | |||
char: A, is digit: false | |||
char: 1, is digit: true | |||
</syntaxhighlight> |
Revision as of 01:59, 22 August 2023
External
Internal
Overview
The unicode
package provide functions to evaluate the properties of runes inside strings.
Introspecting Characters
Also see:
IsDigit()
s := "A 10"
rs := []rune(s)
fmt.Printf("char: %c, is digit: %t\n", rs[0], unicode.IsDigit(rs[0]))
fmt.Printf("char: %c, is digit: %t\n", rs[2], unicode.IsDigit(rs[2]))
prints:
char: A, is digit: false
char: 1, is digit: true