js去除空格在js中,怎么去除字符串的两端含有空格和 需要全部去除 [解决办法]str=str.replace(/^\s+/,"").replace(/\s+$/,"")试试[解决办法]replace(/^(( [解决办法]\s))+[解决办法](( [解决办法]\s))+$/ig,'');