regex - Regexp javascript and replace -


when test regex online (like http://regex101.com), works fine. when test in javascript, doesn't. don't understand i'm doing wrong.

var input = 'fzef zef zef zef (,  ) dezdezfzef  ezf ze'; input = input.replace('/\(\,?\s{0,}?\)/g', ''); console.log(input); 

thank you

you need remove quotes around regex:

input.replace(/\(\,?\s{0,}?\)/g, '') 

Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -