/**
* 去除多余空格函数
* trim:去除两边空格 lTrim:去除左空格 rTrim: 去除右空格
* 用法:
* var str = " hello ";
* str = str.trim();
*/
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, "");
}
[转]JavaScript中的trim函数
最新推荐文章于 2024-04-17 16:45:41 发布