{ var str=str.replace(/</?[^>]*>/gim,"");//去掉所有的html标记 var result=str.replace(/(^s+)|(s+$)/g,"");//去掉前后空格 return result.replace(/s/g,"");//去除文章中间空格}https://www.cnblogs.com/q460021417/p/4968507.html