<!--
// JavaScript Document
// 增加一个名为 trim 的函数作为
// String 构造函数的原型对象的一个方法。去掉字符串前后空格
String.prototype.trim = function()
{
    // 用正则表达式将前后空格
    // 用空字符串替代。
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

//去掉左边空格
function String.prototype.Ltrim()
{
	return this.replace(/(^\s*)/g, "");
}

//去掉右边空格
function String.prototype.Rtrim()
{
	return this.replace(/(\s*$)/g, "");
}

/*
示例：
// 有空格的字符串
var s = "    leading and trailing spaces    ";

// 显示 "    leading and trailing spaces     (35)"
window.alert(s + " (" + s.length + ")");

// 删除前后空格
s = s.trim();
// 显示"leading and trailing spaces (27)"
window.alert(s + " (" + s.length + ")");
*/
//-->