function trim(str){ str = str.replace(/^(\s|\u00A0)+/,''); for(var i=str.length-1; i>=0; i--){ if(/\S/.test(str.charAt(i))){ str = str.substring(0,i+1); break; } } return str; }原文链接:https://www.f2er.com/regex/361080.html
function trim(str){ str = str.replace(/^(\s|\u00A0)+/,''); for(var i=str.length-1; i>=0; i--){ if(/\S/.test(str.charAt(i))){ str = str.substring(0,i+1); break; } } return str; }原文链接:https://www.f2er.com/regex/361080.html