title: Repeating subpatterns regex in C++
body: <p>I have an input <code>...$1::integer,$2::varchar...</code> and am trying to count the amount of <code>$\d::\w+</code> patterns. So, I have this:</p>
  
  <pre><code>std::regex regex("(\\$\\d+\\:\\:\\w+(, ?){0,1})+?(\1)*?", std::regex_constants::icase);
  std::match_results &lt;const char *&gt; matches;
  std::regex_search(str.c_str(), matches, regex);
  </code></pre>
  
  <p>However, this gives the results:</p>
  
  <pre><code>$1::integer,$2::varchar
  </code></pre>
  
  <p>and</p>
  
  <pre><code>$2::varchar
  </code></pre>
  
  <p>How should I change the pattern to obtain <code>$1::integer</code> and <code>$2::varchar</code> as matches?</p>