mirror of
https://github.com/anchore/grype
synced 2024-11-10 06:34:13 +00:00
9050883715
* feat(outputs): allow to set multiple outputs (#648) Signed-off-by: Olivier Boudet <o.boudet@gmail.com> Signed-off-by: Olivier Boudet <olivier.boudet@cooperl.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * feat(outputs): allow to set multiple outputs (#648) review Signed-off-by: Olivier Boudet <olivier.boudet@cooperl.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * use syft format writter pattern and de-emphasize presenter package Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Olivier Boudet <o.boudet@gmail.com> Signed-off-by: Olivier Boudet <olivier.boudet@cooperl.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> Co-authored-by: Alex Goodman <wagoodman@users.noreply.github.com>
15 lines
441 B
Go
15 lines
441 B
Go
package stringutil
|
|
|
|
import "regexp"
|
|
|
|
// MatchCaptureGroups takes a regular expression and string and returns all of the named capture group results in a map.
|
|
func MatchCaptureGroups(regEx *regexp.Regexp, str string) map[string]string {
|
|
match := regEx.FindStringSubmatch(str)
|
|
results := make(map[string]string)
|
|
for i, name := range regEx.SubexpNames() {
|
|
if i > 0 && i <= len(match) {
|
|
results[name] = match[i]
|
|
}
|
|
}
|
|
return results
|
|
}
|