Don't use replaceAll
, use replace
. The former uses regular expressions, and []
are special characters within a regex.
String replaced = input.replace("]", ""); //etc
The double quote is special in Java so you need to escape it with a single backslash ("\""
).
If you want to use a regex you need to escape those characters and put them in a character class. A character class is surrounded by []
and escaping a character is done by preceding it with a backslash \
. However, because a backslash is also special in Java, it also needs to be escaped, and so to give the regex engine a backslash you have to use two backslashes (\\[
).
In the end it should look like this (if you were to use regex):
String replaced = input.replaceAll("[\\[\\]\"]", "");