title: How do I get the Named Groups of a Regex in Delphi?
body: <p>I'm trying to use regex on Delphi to regex a HTML and get some data.</p>
  
  <p>My objective is create a query string with the follow sintax:</p>
  
  <pre><code>?namedGroup1=valueNamedGroup1&amp;namedGroup2=valueNamedGroup2
  </code></pre>
  
  <p>I have n Array of regex:</p>
  
  <pre><code>array[0] = '&lt;div (id="(?&lt;id&gt;[a-zA-Z0-9]+)"|name="(?&lt;name&gt;[a-zA-Z0-9]+))"';
  </code></pre>
  
  <p>My html: </p>
  
  <pre><code>&lt;h1&gt;bla bla bla&lt;/h1&gt; &lt;div id="home"&gt;
  </code></pre>
  
  <p>If I apply this regex using the built in regex in PHP it will return an associative array</p>
  
  <pre><code>RegArray[0] = '&lt;div id="home"&gt;'
  RegArray['id'] = 'home'
  </code></pre>
  
  <p>if I do a foreach I easily get the list of the named groups and I can create my querystring:</p>
  
  <pre><code>?id=home
  </code></pre>
  
  <p>The thing is that I don't know if the regex will match the named group ID or Name and I need to know that.</p>
  
  <p>Delphi only return a simple array</p>
  
  <pre><code>RegArray[0] = '&lt;div id="home"&gt;'
  RegArray[1] = 'home'  // ID or NAME?
  </code></pre>
  
  <p>So, how do I get the named Group and the named Group Value?</p>
  
  <p>here it is my code:</p>
  
  <pre><code>var RegEx: TRegEx;
  begin
   RegEx := TRegEx.Create(array[0], [roIgnoreCase,roMultiline]);
   Match := RegEx.Match(html);
   if (Match.Success) then
   begin
     //get the group here.
   end;
  </code></pre>
  
  <p>I also tried this class: <a href="http://www.regular-expressions.info/delphi.html" rel="nofollow">http://www.regular-expressions.info/delphi.html</a></p>
  
  <p>But no success</p>