my $string = ' this is a string'; $string =~ s/\G\s/:/g; print("$string\n"); # :::this is a string