//去掉字符两端的空白字符 String.prototype.Trim=function () { return this.replace(/(^[tnr]*)|([tnr]*$)/g,''); }; //去掉字符左边的空白字符 String.prototype.LTrim=function () { return this.replace(/^[tnr]/g,''); }; //去掉字符右边的空白字符 String.prototype.RTrim=function () { return this.replace(/[tnr]*$/g,''); };