Suppose i have a string: "10 000,00 EUR"
or "1 000 000,00 EUR"
.
I would like to remove all whitespaces from the string except the last one, so the result would be like: "10000,00 EUR"
or "1000000,00 EUR"
.
At the moment I have something like this:
String myString = "1 000 000 EUR";
myString = myString.replace("\\s(?=\\s*\\s)", "")
I assume that I should use a regex lookahead expression, which matches a whitespace that also has another whitespace following it? Any answer to solve the problem would be appreciated.