In Java, I want to insert a space after a line, but only if the decimal place succeeds with a number or letter. I hope to use the replaceAll method, which uses regular expressions as a parameter. So far I have the following:
String s1="428.0,chf"; s1 = s1.replaceAll(",(\\d|\\w)",", ");
This code successfully distinguishes between the line above and the number where there is a space after the comma. My problem is that I cannot figure out how to write an expression to insert this space. The above code will replace c in the line shown above with a space. This is not what I want.
s1 should look like this after replaceAll : "428.0 chf"
source share