title: Get group names in java regex
body: <p>I'm trying to receive both a pattern &amp; a string and return a map of group name -> matched result.</p>
  
  <p>Example:</p>
  
  <pre><code>(?&lt;user&gt;.*)
  </code></pre>
  
  <p>I would like to return for a map containing "user" as a key and whatever it matches as its value.</p>
  
  <p>the problem is that I can't seem to get the group name from the Java regex api. I can only get the matched values by name or by index. I don't have the list of group names and neither Pattern nor Matcher seem to expose this information.
  I have checked its source and it seems as if the information is there - it's just not exposed to the user.</p>
  
  <p>I tried both Java's java.util.regex and jregex. (and don't really care if someone suggested any other library that is good, supported &amp; high in terms performance that supports this feature).</p>