File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -7,10 +7,11 @@ import (
77 "unicode"
88)
99
10+ var selectCapitalRegexp = regexp .MustCompile (SelectCapital )
11+
1012func caseHelper (input string , isCamel bool , rule ... string ) []string {
1113 if ! isCamel {
12- re := regexp .MustCompile (SelectCapital )
13- input = re .ReplaceAllString (input , ReplaceCapital )
14+ input = selectCapitalRegexp .ReplaceAllString (input , ReplaceCapital )
1415 }
1516 input = strings .Join (strings .Fields (strings .TrimSpace (input )), " " )
1617 if len (rule ) > 0 && len (rule )% 2 != 0 {
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ import (
1010 "unicode"
1111)
1212
13+ var matchWordRegexp = regexp .MustCompile (`[\s]*[\W]\pN` )
14+
1315// input is struct that holds input from user and result
1416type input struct {
1517 Input string
@@ -228,9 +230,8 @@ func (i *input) LcFirst() string {
228230
229231// Lines returns slice of strings by removing white space characters
230232func (i * input ) Lines () []string {
231- input := getInput (* i )
232- matchWord := regexp .MustCompile (`[\s]*[\W]\pN` )
233- result := matchWord .ReplaceAllString (input , " " )
233+ input := getInput (* i )
234+ result := matchWordRegexp .ReplaceAllString (input , " " )
234235 return strings .Fields (strings .TrimSpace (result ))
235236}
236237
You can’t perform that action at this time.
0 commit comments