我正在寻找一种方法来删除字符串中逗号及其后面的所有内容,例如:
important, not so important
我想删除“,not so important”
有什么想法吗?提前感谢!
important, not so important
我想删除“,not so important”
有什么想法吗?提前感谢!
http://www.jsfiddle.net/a5SWU/
var a = "important, not so important";
a = a.split(",")[0];
str.replace(/,.*/,'');
еТМstr.slice(0,str.indexOf(','));
;) - Martin Jespersen