Hey,
Have you tried using string.replace()? The replace function also works with regular expressions, and after replacing you can simply append the original string.
You may use an expression : (s => "0".repeat(Math.max(0, 10 - s.length)) + s)(s) . But too bad there’s no such option in the String.sprintf() function.