Below is the regex I have written to replace the special chars &!)(}{][^"~*?:;\+-
from a string, but somehow it is not able to replace [
& ]
from it as it acts as beginning and closing of regex. How can I do that?
System.out.println(" &!)(}{][^\"~*?:;\\+-".replaceAll("[| |&|!|)|(|}|{|^|\"|~|*|?|:|;|\\\\|+|-]", "_"));
}
The output for now : _______][__________