1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-06 10:47:38 +02:00
lazygit/pkg/utils/regexp.go
2021-12-26 16:48:23 +11:00

18 lines
320 B
Go

package utils
import "regexp"
func FindNamedMatches(regex *regexp.Regexp, str string) map[string]string {
match := regex.FindStringSubmatch(str)
if len(match) == 0 {
return nil
}
results := map[string]string{}
for i, value := range match[1:] {
results[regex.SubexpNames()[i+1]] = value
}
return results
}