删除左右两端空格

function trim(str) {
    return str.replace(/(^\s*)|(\s*$)/g, "");
   }

原文地址:https://www.cnblogs.com/yanjunwu/p/3041792.html