title: Regex is only capturing the last item in group
body: <p>I thought I knew regular expressions but I can't work this out. </p>
  
  <p>Trying to get 56 out of this. </p>
  
  <pre><code>$s = '&lt;a href="../paye/56.html"&gt;';
  </code></pre>
  
  <p>With the following Regex ( PHP - <a href="http://php.net/manual/en/function.preg-match.php" rel="nofollow">preg_match</a>  ) </p>
  
  <pre><code>preg_match('/href="(.*(\d+)\.html)"/',$s,$m);
  </code></pre>
  
  <p>But it only gives me the 6</p>
  
  <pre><code>[
   0 =&gt; 'href="../paye/56.html"',
   1 =&gt; '../paye/56.html',
   2 =&gt; '6' // Need this to be 56
  ]
  </code></pre>
  
  <p>Regex 101 is trying to help with </p>
  
  <blockquote>
    <p>A repeated capturing group will only capture the last iteration. Put
    a capturing group around the repeated group to capture all iterations
    or use a non-capturing group instead if you're not interested in the
    data</p>
  </blockquote>
  
  <p>But all my attempts at putting a capturing group around that capture haven't made a difference. </p>