I want to convert all comma in below string to space or say blank, i tried below code which is only taking care of first comma, I tried global indicator /g as well but that do nothing.
What I am doing wrong?
var str="D'Or, Megan#LastName Jr., FirstName#BMW, somename#What, new";
str=str.replace(',','');
alert(str)
Output
D'Or Megan#LastName Jr., FirstName#BMW, somename#What, new
expected
D'Or Megan#LastName Jr. FirstName#BMW somename#What new
str.replace(/,/g, '')str.replace(',', '', 'g'). From the docs: "To perform a global search and replace, either include the g switch in the regular expression or if the first parameter is a string, include g in the flags parameter."