I am trying to replace the characters "[" and "]" in a string using javascript.
when i do
newString = oldString.replace("[]", "");
then it works fine, but the problem is that I have a lot of these characters in my string and I need to replace all occurrences.
But when I do:
newString = oldString.replace(/[]/g, "");
or
newString = oldString.replace(/([])/g, "");
Nothing happens. I also tried with HTML numbers like
newString = oldString.replace(/[]/g, "");
but it does not work. Any ideas how to do this?
source
share