-
Notifications
You must be signed in to change notification settings - Fork 2
/
string.go
65 lines (54 loc) · 1.79 KB
/
string.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package iterium
// concatMultipleSlices merge more than two slices at once.
func concatMultipleSlices[T any](slices ...[]T) (result []T) {
for _, s := range slices {
result = append(result, s...)
}
return result
}
// AsciiLowercase represents lower case letters.
var AsciiLowercase = []string{
"a", "b", "c", "d", "e", "f", "g",
"h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t", "u",
"v", "w", "x", "y", "z",
}
// AsciiUppercase represents upper case letters.
var AsciiUppercase = []string{
"A", "B", "C", "D", "E", "F", "G",
"H", "I", "J", "K", "L", "M", "N",
"O", "P", "Q", "R", "S", "T", "U",
"V", "W", "X", "Y", "Z",
}
// AsciiLetters is a concatenation of AsciiLowercase and AsciiUppercase.
var AsciiLetters = append(AsciiLowercase, AsciiUppercase...)
// Digits is a slice of the digits in the string type.
var Digits = []string{
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
}
// HexDigits represents hexadecimal letters.
var HexDigits = []string{
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"a", "b", "c", "d", "e", "f", "A", "B", "C", "D",
"E", "F",
}
// OctDigits represents octadecimal letters.
var OctDigits = []string{
"0", "1", "2", "3", "4", "5", "6", "7",
}
// Punctuation is a slice of ASCII characters that
// are considered punctuation marks in the C locale
var Punctuation = []string{
"!", "\"", "#", "$", "%", "&", "'", "(",
")", "*", "+", ",", "-", ".", "/", ":",
";", "<", "=", ">", "?", "@", "[", "\\",
"]", "^", "_", "`", "{", "|", "}", "~",
}
// Whitespace contains all ASCII characters that are considered whitespace
var Whitespace = []string{
" ", "\t", "\n", "\r", "\x0b", "\x0c",
}
// Printable is a slice of ASCII characters which are considered printable.
var Printable = concatMultipleSlices(
AsciiLetters, Digits, Punctuation, Whitespace,
)