trim1(str){ return str.replace(/\s*/g,""); // 清除所有空格 }; trim2(str){ return str.replace(/(^\s*)|(\s*$)/g,""); // 清除字符串前后的空格 }