标签: javascript regex split
我想从字符串的开头/结尾删除所有不必要的空格和逗号。
例如; ,11,22,33,应该变成11,22,33
我试过了,
var str=",22,33,44,55,"; var splitted = str.split(","); alert(splitted[0]);
但显示空格
答案 0 :(得分:4)
尝试:
var str=",22,33,44,55,"; str.replace(/^[\s,]+|[\s,]+$/g, '').split(",");