HaBo HaBo - 5 months ago 35
Javascript Question

javascript Replace all ( and ) in s string

How can i replace all Parenthesis in a string using javascript

or replace all special characters in string.

i tried this

mystring= mystring.replace(/"/g, "").replace(/'/g, "").replace("(", "").replace(")", "");

this works for all double and single quotes but for parenthesis this only replaces first parenthesis in the string

how can i make it work to replace all parenthesis in the string


Try the following:

mystring= mystring.replace(/"/g, "").replace(/'/g, "").replace(/\(|\)/g, "");

A little bit of REGEX to grab those pesky parentheses.