title: Capture a Repeating Group in Python using RegEx (see example)
body: <p>I am writing a regular expression in python to capture the contents inside an SSI tag.</p>
  
  <p>I want to parse the tag: </p>
  
  <pre><code>&lt;!--#include file="/var/www/localhost/index.html" set="one" --&gt;
  </code></pre>
  
  <p>into the following components:</p>
  
  <ul>
  <li>Tag Function (ex: <code>include</code>, <code>echo</code> or <code>set</code>)</li>
  <li>Name of attribute, found before the <code>=</code> sign</li>
  <li>Value of attribute, found in between the <code>"</code>'s</li>
  </ul>
  
  <p>The problem is that I am at a loss on how to grab these <em>repeating groups</em>, as name/value pairs may occur <strong>one or more times</strong> in a tag. I have spent hours on this.</p>
  
  <p>Here is my current regex string: </p>
  
  <pre><code>^\&lt;\!\-\-\#([a-z]+?)\s([a-z]*\=\".*\")+? \-\-\&gt;$
  </code></pre>
  
  <p>It captures the <code>include</code> in the first group and <code>file="/var/www/localhost/index.html" set="one"</code> in the second group, but what I am after is this:</p>
  
  <pre><code>group 1: "include"
  group 2: "file"
  group 3: "/var/www/localhost/index.html"
  group 4 (optional): "set"
  group 5 (optional): "one"
  
  (continue for every other name="value" pair)
  </code></pre>
  
  <p><br />
  <a href="http://regex101.com/r/rD5aC2/3" rel="nofollow">I am using this site to develop my regex</a></p>