微调正则表达式

I am working with some regular expressions in go, and its not a direct process, ie takes time to work through and understand from items I've found and reading fast through the manual; any input on refining the following would be appreciated to speed up the process.

// {aa,bb,cc,dd, etc.}, {a+,b+,c+}
regexp.MustCompile(`\B\{([\w-]+)(.*,)([\w-]+)(?:,[\w-]+=[\w-]+)*\}`)
// above captures {a+, b+, c}, but not {a+,b+,c+}

// {1-9}, {1-9,10,19,20-52}
regexp.MustCompile(`\B\{([\d]?)-([\d]?)(?:,[\d]?=[\d]?)*\}`)
// the first is fine, but no idea on how to do the latter, i.e. multiple ranges that might have free standing addons, tricky, maybe beyond a regexp

// {a-f}, {A-F}, {x-C}
regexp.MustCompile(`\B\{([a-zA-Z]?)-([a-zA-Z]?)(?:,[a-zA-Z]?=[a-zA-Z]?)*\}`)

I'm not sure I need the (?: part, it is something found, I just need to recognize separate instances of sequences above (comma separated, number range, character range) bracketed by {} in text I'm parsing.

The problem is easier to tackle if you break the parsing down into steps. You could start with something like:

http://play.golang.org/p/ugqMmaeKEs

s := "{aa,bb,cc,  dd}, {a+,\tb+,c+}, {1-9}, {1-9,10,19,20-52}, {a-f}, {A-F}, {x-C}, {}"

// finds the groups of characters captured in {}
matchGroups := regexp.MustCompile(`\{(.+?)\}`)
// splits each captured group of characters
splitParts := regexp.MustCompile(`\s*,\s*`)

parts := [][]string{}
for _, match := range matchGroups.FindAllStringSubmatch(s, -1) {
    parts = append(parts, splitParts.Split(match[1], -1))
}

Now you have all the parts grouped into slices, and can parse the syntax of the individual pieces without having to match all combinations via a regex.