I have the below variable in JavaScript. I want to remove the "comma" sign using jQuery /JavaScript.
var test = ",,2,4,,,3,,3,,," Expected output: var test = "2,4,3,3"
please advice
I have the below variable in JavaScript. I want to remove the "comma" sign using jQuery /JavaScript.
var test = ",,2,4,,,3,,3,,," Expected output: var test = "2,4,3,3"
please advice
var test = ",,2,4,,,3,,3,,,";
document.write(test.replace(/,+/g,',').replace(/^,|,$/g,''));
replace(/,+/g,',')
- To remove multiple comma with one.replace(/^,|,$/g,'')
- To remove comma at starting and ending.