title: Using named matches from Go regex
body: <p>I'm coming from Python, so I'm probably just not looking at this the right way. I'd like to create a fairly complicated regex and be able to access the fields match by name. I can't seem to find a good example. The closest I've managed to get is this:</p>
  
  <pre><code>package main
  
  import (
    "fmt"
    "regexp"
  )
  
  var myExp = regexp.MustCompile(`(?P&lt;first&gt;\d+)\.(\d+).(?P&lt;second&gt;\d+)`)
  
  func main() {
    fmt.Printf("%+v", myExp.FindStringSubmatch("1234.5678.9"))
  
    match := myExp.FindStringSubmatch("1234.5678.9")
      for i, name := range myExp.SubexpNames() {
          fmt.Printf("'%s'\t %d -&gt; %s\n", name, i, match[i])
      }
      //fmt.Printf("by name: %s %s\n", match["first"], match["second"])
  }
  </code></pre>
  
  <p>The commented out line is how I would expect to access the named fields in Python. What's the equivalent way to do this in go?</p>
  
  <p>Or if I need to convert the match to a map, what's the most idiomatic way in go to make and then access the map?</p>