title: Regex - get multiple captures at multiple lines and their positions
body: <p>I've been trying to do this for several days but still I don't get the right result.</p>
  
  <p>I need to get all captures from a whole string (including newlines) but don't return after first match. I have this regex: <code>(\d+)\s*;</code>. The result should be only numbers (not the spaces and semicolon after) and it should take them from the whole input string (which is multiline).</p>
  
  <p>So, for example, from this input:</p>
  
  <pre><code>5;
  6 ;
   7;
   8 ;
  </code></pre>
  
  <p>It should return "5", "6", "7" and "8".</p>
  
  <p>Anyone know how to do that in c++?</p>
  
  <p>Thanks!</p>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>From links mentioned in comments, I came up with this code:</p>
  
  <pre><code>std::regex regex(regex_str, std::regex_constants::icase);
  
  for (std::sregex_iterator it = std::sregex_iterator(input.begin(), input.end(), regex); it != std::sregex_iterator(); ++it)
  {
      std::smatch m = *it;
  
      std::cout &lt;&lt; "\t" &lt;&lt; m[1].str() &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>It works just fine but there is one thing I forgot to mention: I also need to get the position of every capture. Using <code>m.position()</code> I can get the position of the whole match, but if there's something before the capturing group I'm looking for, it tells me an incorrect position. So, how can I get a position of the capture?</p>