Please anyone tell me what is the difference between:
.replaceAll("\\s","");
.replaceAll("\\s+","");
- and
.replaceAll("\\s+$","");
Please anyone tell me what is the difference between:
.replaceAll("\\s","");
.replaceAll("\\s+","");
.replaceAll("\\s+$","");
s.replaceAll("\\s", "")
Replace each space character with nothing.
s.replaceAll("\\s+", "")
Replace each group of 1 or more spaces with nothing.
s.replaceAll("\\s+$", "")
Replace each group of 1 or more spaces at the end of the string with nothing.
All of these special characters are explained well in the javadoc.