You can use String.replace instead of String.replaceAll for better performance , as it searches for the exact sequence and does not need regular expressions.
String test = "watching tv (at home)"; test = test.replace("(", " "); test = test.replace(")", " "); test = test.replace("[", " "); test = test.replace("]", " "); test = test.replace("{", " "); test = test.replace("}", " ");
If you work with texts, I recommend that you replace the brackets with blank space to avoid combining words: watching tv(at home) -> watching tvat home
Javi fernΓ‘ndez
source share