HaBo HaBo - 1 year ago 83
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

Answer Source

Try the following:

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

A little bit of REGEX to grab those pesky parentheses.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download