-
Notifications
You must be signed in to change notification settings - Fork 1
/
string_functions.go
152 lines (132 loc) · 5.09 KB
/
string_functions.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package nqb
/**
* Returned expression results in True if the string expression contains the substring.
*/
func Contains(expression interface{}, substring string) *Expression {
return X("CONTAINS(" + toString(expression) + ", \"" + substring + "\")")
}
/**
* Returned expression results in the conversion of the string so that the first letter
* of each word is uppercase and every other letter is lowercase.
*/
func InitCap(expression interface{}) *Expression {
return X("INITCAP(" + toString(expression) + ")")
}
/**
* Returned expression results in the conversion of the string so that the first letter
* of each word is uppercase and every other letter is lowercase.
*/
func Title(expression interface{}) *Expression {
return X("TITLE(" + toString(expression) + ")")
}
/**
* Returned expression results in the length of the string expression.
*/
func Length(expression interface{}) *Expression {
return X("LENGTH(" + toString(expression) + ")")
}
/**
* Returned expression results in the given string expression in lowercase
*/
func Lower(expression interface{}) *Expression {
return X("LOWER(" + toString(expression) + ")")
}
/**
* Returned expression results in the string with all leading white spaces removed.
*/
func Ltrim(expression interface{}) *Expression {
return X("LTRIM(" + toString(expression) + ")")
}
/**
* Returned expression results in the string with all leading chars removed (any char in the characters string).
*/
func LTRIM(expression interface{}, characters string) *Expression {
return X("LTRIM(" + toString(expression) + ", \"" + characters + "\")")
}
/**
* Returned expression results in the first position of the substring within the string, or -1.
* The position is zero-based, i.e., the first position is 0.
*/
func Position(expression interface{}, substring string) *Expression {
return X("POSITION(" + toString(expression) + ", \"" + substring + "\")")
}
/**
* Returned expression results in the string formed by repeating expression n times.
*/
func Repeat(expression interface{}, n int) *Expression {
return X("REPEAT(" + toString(expression) + ", " + toString(n) + ")")
}
/**
* Returned expression results in a string with all occurrences of substr replaced with repl.
*/
func Replace(expression interface{}, substring, repl string) *Expression {
return X("REPLACE(" + toString(expression) + ", \"" + substring + "\", \"" + repl + "\")")
}
/**
* Returned expression results in a string with at most n occurrences of substr replaced with repl.
*/
func REPLACE(expression interface{}, substring, repl string, n int) *Expression {
return X("REPLACE(" + toString(expression) + ", \"" + substring + "\", \"" + repl + "\", " + toString(n) + ")")
}
/**
* Returned expression results in the string with all trailing white spaces removed.
*/
func Rtrim(expression interface{}) *Expression {
return X("RTRIM(" + toString(expression) + ")")
}
/**
* Returned expression results in the string with all trailing chars removed (any char in the characters string).
*/
func RTRIM(expression interface{}, characters string) *Expression {
return X("RTRIM(" + toString(expression) + ", \"" + characters + "\")")
}
/**
* Returned expression results in a split of the string into an array of substrings
* separated by any combination of white space characters.
*/
func Split(expression interface{}) *Expression {
return X("SPLIT(" + toString(expression) + ")")
}
/**
* Returned expression results in a split of the string into an array of substrings separated by sep.
*/
func SPLIT(expression interface{}, sep string) *Expression {
return X("SPLIT(" + toString(expression) + ", \"" + sep + "\")")
}
/**
* Returned expression results in a substring from the integer position of the given length.
*
* The position is zero-based, i.e. the first position is 0.
* If position is negative, it is counted from the end of the string -1 is the last position in the string.
*/
func Substr(expression interface{}, position, length int) *Expression {
return X("SUBSTR(" + toString(expression) + ", " + toString(position) + ", " + toString(length) + ")")
}
/**
* Returned expression results in a substring from the integer position to the end of the string.
*
* The position is zero-based, i.e. the first position is 0.
* If position is negative, it is counted from the end of the string -1 is the last position in the string.
*/
func SUBSTR(expression interface{}, position int) *Expression {
return X("SUBSTR(" + toString(expression) + ", " + toString(position) + ")")
}
/**
* Returned expression results in the string with all leading and trailing white spaces removed.
*/
func Trim(expression interface{}) *Expression {
return X("TRIM(" + toString(expression) + ")")
}
/**
* Returned expression results in the string with all leading and trailing chars removed
* (any char in the characters string).
*/
func TRIM(expression interface{}, characters string) *Expression {
return X("TRIM(" + toString(expression) + ", \"" + characters + "\")")
}
/**
* Returned expression results in uppercase of the string expression.
*/
func Upper(expression interface{}) *Expression {
return X("UPPER(" + toString(expression) + ")")
}