-
Notifications
You must be signed in to change notification settings - Fork 0
/
strings.go
132 lines (113 loc) · 3 KB
/
strings.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package strmod
import (
"strings"
"unicode"
)
// Title is executing stdlib strings.Title().
func Title() Modifier {
return func(s string) string {
return strings.Title(s)
}
}
// ToLower is executing stdlib strings.ToLower().
func ToLower() Modifier {
return func(s string) string {
return strings.ToLower(s)
}
}
// ToLowerSpecial is executing stdlib strings.ToLowerSpecial().
func ToLowerSpecial(c unicode.SpecialCase) Modifier {
return func(s string) string {
return strings.ToLowerSpecial(c, s)
}
}
// ToTitle is executing stdlib strings.ToTitle().
func ToTitle() Modifier {
return func(s string) string {
return strings.ToTitle(s)
}
}
// ToTitleSpecial is executing stdlib strings.ToTitleSpecial().
func ToTitleSpecial(c unicode.SpecialCase) Modifier {
return func(s string) string {
return strings.ToTitleSpecial(c, s)
}
}
// ToUpper is executing stdlib strings.ToUpper().
func ToUpper() Modifier {
return func(s string) string {
return strings.ToUpper(s)
}
}
// ToUpperSpecial is executing stdlib strings.ToUpperSpecial().
func ToUpperSpecial(c unicode.SpecialCase) Modifier {
return func(s string) string {
return strings.ToUpperSpecial(c, s)
}
}
// Trim is executing stdlib strings.Trim().
func Trim(cutset string) Modifier {
return func(s string) string {
return strings.Trim(s, cutset)
}
}
// TrimFunc is executing stdlib strings.TrimFunc().
func TrimFunc(f func(rune) bool) Modifier {
return func(s string) string {
return strings.TrimFunc(s, f)
}
}
// TrimLeft is executing stdlib strings.TrimLeft().
func TrimLeft(cutset string) Modifier {
return func(s string) string {
return strings.TrimLeft(s, cutset)
}
}
// TrimLeftFunc is executing stdlib strings.TrimLeftFunc().
func TrimLeftFunc(f func(rune) bool) Modifier {
return func(s string) string {
return strings.TrimLeftFunc(s, f)
}
}
// TrimPrefix is executing stdlib strings.TrimPrefix().
func TrimPrefix(prefix string) Modifier {
return func(s string) string {
return strings.TrimPrefix(s, prefix)
}
}
// TrimRight is executing stdlib strings.TrimRight().
func TrimRight(cutset string) Modifier {
return func(s string) string {
return strings.TrimRight(s, cutset)
}
}
// TrimRightFunc is executing stdlib strings.TrimRightFunc().
func TrimRightFunc(f func(rune) bool) Modifier {
return func(s string) string {
return strings.TrimRightFunc(s, f)
}
}
// TrimSpace is executing stdlib strings.TrimSpace().
func TrimSpace() Modifier {
return func(s string) string {
return strings.TrimSpace(s)
}
}
// TrimSuffix is executing stdlib strings.TrimSuffix().
func TrimSuffix(suffix string) Modifier {
return func(s string) string {
return strings.TrimSuffix(s, suffix)
}
}
// Replace is executing stdlib strings.Replace().
func Replace(old, new string, n int) Modifier {
return func(in string) string {
return strings.Replace(in, old, new, n)
}
}
// ReplaceAll is executing stdlib strings.ReplaceAll().
func ReplaceAll(old, new string) Modifier {
return func(in string) string {
return strings.ReplaceAll(in, old, new)
}
}