String.prototype.TrimEnd = function(s) {
s = (s ? s : "\\s");
s = ("(" + s + ")");
var reg_rTrim = new RegExp(s + "*$", "g");
var returnvalue=this.replace(reg_rTrim, "");
if(returnvalue.charAt(returnvalue.length - 1)==".") //最后一位是小数点时去除
returnvalue=returnvalue.substr(0,returnvalue.length - 1);
return returnvalue;
};
String.prototype.TrimStart = function(s) {
s = (s ? s : "\\s"); //没有传入参数的,默认去空格
s = ("(" + s + ")");
var reg_lTrim = new RegExp("^" + s + "*", "g"); //拼正则
return this.replace(reg_lTrim, "");
};
String.prototype.Trim = function(s) {
s = (s ? s : "\\s");
s = ("(" + s + ")");
var reg_trim = new RegExp("(^" + s + "*)|(" + s + "*$)", "g");
return this.replace(reg_trim, "");
};