You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: parse.go
    path of file: ./repos/grype/internal/stringutil
    
    the code of the file until where you have to start completion: package stringutil

import "regexp"

// MatchCaptureGroups takes a regular expression and string and returns all of th
    
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
}