title: C#: Regex match closest
body: <pre><code>&lt;table class="listProvision" class="itable"&gt;
      &lt;tr&gt;
          &lt;td class="whatever"&gt;some infos&lt;/td&gt;
          &lt;td&gt;some more infos&lt;/td&gt;
          &lt;td&gt;13908402&lt;/td&gt;
          &lt;td&gt;hello world&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="whatever"&gt;some infos&lt;/td&gt;
          &lt;td&gt;some more infos&lt;/td&gt;
          &lt;td id="num"&gt;13908402&lt;/td&gt;
          &lt;td&gt;hello world&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Given the above sample HTML, <strong>how can I properly parse all existences of <code>&lt;tr&gt;...&lt;/tr&gt;</code> between the <code>table</code> with class <code>listProvision</code></strong>?</p>
  
  <p>I tried: <code>&lt;table.*?listProvision.*?&gt;(?:.*?&lt;tr.*?&gt;(.*?)&lt;/tr&gt;)+.*?&lt;/table&gt;</code>, but I can't figure out what's wrong. There is never going to be any complicated html pulled into this regex so don't worry about that.</p>