perl -p -e 'if(s/^(\d+)://g) { my $x = $1; s/\d+/$x/g; }' foo.txt