A very noob question..
I want to replace all the occurance of "." in a string with empty space..
So this is what I tried
String s = "1.2.3.4";
System.out.println(s);
s = s.replaceAll(".", " ");
System.out.println(s);
But the second print is an empty print?
What did i missed here?
You want to escape the .
. Otherwise, it can match anything.
Try s.replaceAll("\\.", " ")
instead.
Use String.replace(char, char) instead of String.replaceAll
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With