标签: javascript jquery split
我在JavaScript中有以下变量。我想使用jQuery / JavaScript删除“逗号”符号。
var test = ",,2,4,,,3,,3,,," Expected output: var test = "2,4,3,3"
请咨询
答案 0 :(得分:1)
将 replace() 与 regex
replace()
regex
var test = ",,2,4,,,3,,3,,,"; document.write(test.replace(/,+/g,',').replace(/^,|,$/g,''));
replace(/,+/g,',')
replace(/^,|,$/g,'')