diff --git a/helper.go b/helper.go index 16d4a61..069e353 100644 --- a/helper.go +++ b/helper.go @@ -7,10 +7,11 @@ import ( "unicode" ) +var selectCapitalRegexp = regexp.MustCompile(SelectCapital) + func caseHelper(input string, isCamel bool, rule ...string) []string { if !isCamel { - re := regexp.MustCompile(SelectCapital) - input = re.ReplaceAllString(input, ReplaceCapital) + input = selectCapitalRegexp.ReplaceAllString(input, ReplaceCapital) } input = strings.Join(strings.Fields(strings.TrimSpace(input)), " ") if len(rule) > 0 && len(rule)%2 != 0 {