Initialize Index Groups regex just once
This commit is contained in:
@@ -18,12 +18,14 @@ type IndexGroups map[string]string
|
|||||||
// for grouping accented characters (such as A, \u00C0 and \u00C1)
|
// for grouping accented characters (such as A, \u00C0 and \u00C1)
|
||||||
//
|
//
|
||||||
// Files and folders that are not covered by an index entry will be placed under the index entry "#".
|
// Files and folders that are not covered by an index entry will be placed under the index entry "#".
|
||||||
|
|
||||||
|
var indexGroupsRx = regexp.MustCompile(`(.+)\((.+)\)`)
|
||||||
|
|
||||||
func ParseIndexGroups(spec string) IndexGroups {
|
func ParseIndexGroups(spec string) IndexGroups {
|
||||||
parsed := make(IndexGroups)
|
parsed := make(IndexGroups)
|
||||||
split := strings.Split(spec, " ")
|
split := strings.Split(spec, " ")
|
||||||
re := regexp.MustCompile(`(.+)\((.+)\)`)
|
|
||||||
for _, g := range split {
|
for _, g := range split {
|
||||||
sub := re.FindStringSubmatch(g)
|
sub := indexGroupsRx.FindStringSubmatch(g)
|
||||||
if len(sub) > 0 {
|
if len(sub) > 0 {
|
||||||
i := 0
|
i := 0
|
||||||
chars := strings.Split(sub[2], "")
|
chars := strings.Split(sub[2], "")
|
||||||
|
|||||||
Reference in New Issue
Block a user