$string = "On 0 8 February 2 0 1 4 , he visited the fair";
I want to replace the spaces between the numbers, so it becomes "On 08 February 2014, he visited the fair"
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.
This is an idea of what I'm trying to achieve:
$string =~ s/([0-9]\s)+/substr($string,$-[0],$+[0]-$-[0])/g;
but it won't work since substr is not treated as a function within the regex. Any ideas?