JS替换字符串多余的空格符

var str = 'sdfsdfds      ';
str.replace(/(^\s*)|(\s*$)/g, "");

  

posted @ 2018-03-22 15:23  小小lomo  阅读(266)  评论(0)    收藏  举报