title: QT C++ QRegularExpression multiple matches
body: <p>I want to extract Information from a QString (.html) by using Regular Expressions. I explicitly want to use Regex (no Parser Solutions) and the class <a href="http://qt-project.org/doc/qt-5.0/qtcore/qregularexpression.html" rel="nofollow noreferrer">QRegularExpression</a> (for several reasons e.g.: <a href="http://dangelog.wordpress.com/2012/04/07/qregularexpression/" rel="nofollow noreferrer">Reasons</a>). </p>
  
  <p>For simplification aspects here is an problem equivalent task.</p>
  
  <p><strong><em>Constructed source string:</em></strong> </p>
  
  <pre><code>&lt;foo&gt;&lt;bar s&gt;INFO1.1&lt;/bar&gt; &lt;/ qux&gt; &lt;peter&gt;&lt;/peter&gt;&lt;bar e&gt;INFO1.2
  &lt;/bar&gt;&lt;fred&gt;&lt;/ senseless&gt;&lt;/fred&gt;&lt;/ xx&gt;&lt;lol&gt;&lt;/lol&gt;&lt;/foo&gt;&lt;bar s&gt;INFO2.1&lt;/bar&gt;
  &lt;/ nothing&gt;&lt;endlessSenselessTags&gt;&lt;/endlessSenselessTags&gt;&lt;rofl&gt;
  &lt;bar e&gt;INFO2.2&lt;/bar&gt;&lt;/rofl&gt;
  </code></pre>
  
  <p>*Note:*There could be more or less INFOs and additional sensless tags. (6 Infos e.g.)</p>
  
  <p><strong><em>Wanted:</em></strong> </p>
  
  <p>Info1.1 and Info1.2 and Info2.1 and Info2.2 (e.g. in List)</p>
  
  <p><strong><em>Attempt</em></strong></p>
  
  <p>1.</p>
  
  <pre><code>QRegularExpression reA(".*&lt;bar [es]&gt;(.*)&lt;/bar&gt;.*", QRegularExpression::DotMatchesEverythingOption);
  </code></pre>
  
  <p>-></p>
  
  <pre><code>INFOa&lt;/bar&gt; &lt;/ qux&gt; &lt;peter&gt;&lt;/peter&gt;&lt;bar e&gt;INFOb
      &lt;/bar&gt;&lt;fred&gt;&lt;/ senseless&gt;&lt;/fred&gt;&lt;/ xx&gt;&lt;lol&gt;&lt;/lol&gt;&lt;/foo&gt;&lt;bar s&gt;INFOc&lt;/bar&gt;
      &lt;/ nothing&gt;&lt;endlessSenselessTags&gt;&lt;/endlessSenselessTags&gt;&lt;rofl&gt;
      &lt;bar e&gt;INFOd
  </code></pre>
  
  <p>2.</p>
  
  <pre><code>QRegularExpression reA("(.*&lt;bar [es]&gt;(.*)&lt;/bar&gt;.*)*", QRegularExpression::DotMatchesEverythingOption);
  </code></pre>
  
  <p>->senseless</p>
  
  <p><strong><em>Problem:</em></strong>
  The Regex is always related to the whole String. <code>&lt;bar s&gt;INFO&lt;/bar&gt;&lt;bar s&gt;INFO&lt;/bar&gt;</code>  would select the first <code>&lt;bar s&gt;</code> and the last and <code>&lt;/bar&gt;</code>. Wanted is first <em></em></p>
  
  <p>With QRegExp there seems to be a solution, but i want to do this with QRegularExpression.</p>