String.prototype.trim = function(){ // 用正则表达式将前后空格 // 用空字符串替代。 return this.replace(/(^\s*)|(\s*$)/g, ""); }