Javascript中为String对象添加 Trim() 方法
<script language=Javascript>  //自己动手为string添加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, "");}
var str = "  meizz    ";
alert(str.Trim());
alert(str.Ltrim());
alert(str.Rtrim());
</script>