1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/utils/regexp.go

18 lines
320 B
Go
Raw Normal View History

2021-12-26 06:56:05 +02:00
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
}