title: Golang Regexp Named Groups and Submatches
body: <p>I am trying to match a regular expression and get the capturing group name for the match. This works when the regular expression only matches the string once, but if it matches the string more than once, <code>SubexpNames</code> doesn't return the duplicated names.</p>
  
  <p>Here's an example:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "regexp"
  )
  
  func main() {
      re := regexp.MustCompile("(?P&lt;first&gt;[a-zA-Z]+) ")
      fmt.Printf("%q\n", re.SubexpNames())
      fmt.Printf("%q\n", re.FindAllStringSubmatch("Alan Turing ", -1))
  }
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>["" "first"]
  [["Alan " "Alan"] ["Turing " "Turing"]]
  </code></pre>
  
  <p>Is it possible to get the capturing group name for each submatch?</p>