Hi,
Goal: prefix each number in a string with 1-5 zeros depending on the number
e.g. if it's less than 10 then prepend 4 zeros, if it's two digits then prefix three zeros.
This basically prefixes each number with zeros so each number is 5 digits.
Source
String str = "1 - test 86";
Desired Result:
String str = "00001 - test 00086";
I've tried this but this adds zeros to every number
str = str .replaceAll("(\\d+)", "00000$1");
any ideas?