javascript - how to replace special character with empty string -


i have following string:

str = '( name1 || name2 || name3 )' 

and want replace '(' , ')' empty string

have tried didn't work

str.replace(/[()]+/g,'') 

please advice. want find string be

str = 'name1 || name2 || name3' 

i mean, you've got of there:

var str = '( name1 || name2 || name3 )'; str = str.replace(/[()]+/g,''); console.log(str); 

i think forgot assign str in middle statement. also, want trim middle:

str = str.replace(/[()]+/g,'').trim();