正则 清除字符串前后的空格 function trim(str) { if (str && typeof str === "string") { return str.replace(/(^\s*)|(\s*)$/g,""); //去除前后空白符 } } 相关文章: 2021-12-25 2021-07-14 2022-12-23 2021-10-31 2021-11-17 2022-02-11 2022-12-23