largeQ
package mainimport ( "fmt" "regexp")func myRegx(s string) (n string, o []string, v []string) { regx := regexp.MustCompile(`(\S+) \(([>=<]+)\s+([\d\.]*)(,\s+([>=<]+)\s+([\d.]+))?\)`) b := regx.FindStringSubmatch(s) n = b[1] if len(b) < 4 { o = append(o, b[2]) v = append(v, b[3]) } else { o = append(o, b[2]) v = append(v, b[3]) o = append(o, b[5]) v = append(v, b[6]) } return n, o, v}func main() { n, o, v := myRegx("b (>= 1.1, < 2.0)") fmt.Printf("n: %v o:%v v:%v\n", n, o, v) n, o, v = myRegx("a (>= 1.1)") fmt.Printf("n: %v o:%v v:%v\n", n, o, v)}