1.去除字符串前置后置空格: String.prototype.trimStr = function () { return this.replace(/^\s+|\s+$/g,''); } 转载于:https://www.cnblogs.com/glory0727/p/8973330.html