I want to delete all the full stops ( . ) in a string.
Therefore I tried: inpt = inpt.replaceAll(\".\", \"\");
,
but instead of deleting only the full st
Don't use replaceAll()
, use replace()
:
inpt = inpt.replace(".", "");
It is a common misconception that replace()
doesn't replace all occurrences, because there's a replaceAll()
method, but in fact both replace all occurrences. The difference between the two methods is that replaceAll()
matches on a regex (fyi a dot in regex means "any character", which explains what you were experiencing) whereas replace()
matches on a literal String.