I want to replace all the occurrences of a group in a string.
String test = "###,##.##0.0########";
System.out.println(test);
test = test.replaceAll("\\.0(#)", "0");
System.out.println(test);
The result I am trying to obtain is ###,##.##0.000000000
Basically, I want to replace all #
symbols that are trailing the .0
.
I've found this about dynamic replacement but I can't really make it work.
The optimal solution will not take into account the number of hashes to be replaced (if that clears any confusion).
#
following.0
to0
? – Bekah0
can there be in an input string? Unlimited, or say, a hundred? – Headstone