title: Search and replace dynamically in perl regex
body: <pre><code>$string = "On 0 8 February 2 0 1 4 , he visited the fair";
  </code></pre>
  
  <p>I want to replace the spaces between the numbers, so it becomes <code>"On 08 February 2014, he visited the fair"</code></p>
  
  <p>How can I do this with regex? I can do a for loop index by index, but given large amounts of text, it will be slow. </p>
  
  <p>This is an idea of what I'm trying to achieve:</p>
  
  <pre><code>$string =~ s/([0-9]\s)+/substr($string,$-[0],$+[0]-$-[0])/g;
  </code></pre>
  
  <p>but it won't work since substr is not treated as a function within the regex. Any ideas?</p>