You were close enough, but should correspond to at least one digit, and then :, and part of the substitution should return the desired result, and not print it.
my $s = "1,2,4 0:5 1:10 3:14";
$s =~ s/([0-9]+) (?=:)/ $1+1 /xge;
print $s, "\n";
Dry27 source
share