去掉左空格 右空格 全部空格 附加到String的原生对象

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, "");
}
posted @ 2011-02-23 16:45  流失的痕迹  阅读(222)  评论(0)    收藏  举报