String.prototype.Ltrim=function()
{
//用正则表达式将前空格
//用空字符串替代。
returnthis.replace(/(^\s*)/g,"");
};
String.prototype.Rtrim=function()
{
//用正则表达式将后空格
//用空字符串替代。
returnthis.replace(/(\s*$)/g,"");
};
String.prototype.trim=function()
{
//用正则表达式将前后空格
//用空字符串替代。
returnthis.replace(/(^\s*)|(\s*$)/g,"");
};
varste="aaaabb";
alert("@"+ste.Ltrim()+"@");
alert("@"+ste.Rtrim()+"@");
alert("@"+ste.trim()+"@");