【学习篇】JavaScript去除字符串空格
2010-10-29 21:29 Simon.Jiang 阅读(296) 评论(0) 收藏 举报
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, "");
}
var s = " leading and trailing spaces "; s = s.Trim();
浙公网安备 33010602011771号