去除空格 2021年2月12日 | Js | 阅读 去除空格 function trim(str) { // 去除头和尾 return str.replace(/^[" "||" "]*/,"").replace(/[" "|" "]*$/,""); //去除所有空格 return str.replace(/\s/g,''); //去除右边所有空格 return str.replace(/(\s*$)/g,""); } 空格