package helper import "regexp" // GetRegexpParams gets a map of named regexp group matches // use pe. (?P\d{4})-(?P\d{2})-(?P\d{2}) as regexp func GetRegexpParams(regEx *regexp.Regexp, str string) (paramsMap map[string]string) { match := regEx.FindStringSubmatch(str) paramsMap = make(map[string]string) for i, name := range regEx.SubexpNames() { if i > 0 && i <= len(match) { paramsMap[name] = match[i] } } return }