javascript去除左右两边空格
记录一下,javascript去除左右两边空格的一个函数:
trim:去除两边空格 lTrim:去除左空格 rTrim: 去除右空格
String.prototype.trim= function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.lTrim= function()
{
return this.replace(/(^\s*)/g, "");
}
String.prototype.rTrim= function()
{
return this.replace(/(\s*$)/g, "");
}