s/ ( # Capture group $1 \d+ # Digits (?: # Group (no capturing) (optional group) \. # a dot \d+ # Digits )? ) # End capture $1 (?= # Open look-ahead (?: # Group (no capturing) \s+ # Whitespace \S+ # Non-whitespace ) {4} # Match previous group exactly four times $ # Match end of line ) /int ($1) . " " x (length($1) - length(int($1)))/egx;