I have a string and I need to remove these symbols: -- + [ ] { } ( ) \ /
For example:
String clean = "This \ is / an example. This -- is + an [(example)].";
clean = clean.replaceAll("[/[()/]]", "");
clean = clean.replaceAll("/-/-", "");
clean = clean.replaceAll("\\/","");
clean = clean.replaceAll("\\\\", " ");
clean = clean.replaceAll("\\+", "");
return clean.replaceAll("[ ]+", " ").trim();
My output should be: This is an example. This is an example.
My code does not remove everything I need and also I would like to know if there is a shorter way to do this.
--
Just some particularities I should mention: -
should be removed only if there are two together.
/
should be replaced by a whitespace. I'm going to try to adapt your solutions here. Thanks.