1. http://www.softwhy.com/article-6454-1.html
String.prototype.ResetBlank=function(){ var regEx = /\s+/g; return this.replace(regEx, ' '); };var str="antzone is good boy";console.log(str.length);console.log(str.ResetBlank().length);
2.
str= str.replace(/\s+/g,' ') //将连续多个空格只留下一个空格