扩张js的String——trim

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

//去掉字符左边的空白字符  
String.prototype.LTrim=function () {  
    return this.replace(/^[ ]/g,'');  
};  

//去掉字符右边的空白字符  
String.prototype.RTrim=function () {  
    return this.replace(/[ ]*$/g,'');  
};

原文地址:https://www.cnblogs.com/huangf714/p/5900558.html