Sady Home

Note my coding life

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
<script language="JavaScript">
    
// object of the String constructor. 
    String.prototype.trim = function() 
    

        
// Use a regular expression to replace leading and trailing 
        // spaces with the empty string 
        return this.replace(/(^\s*)|(\s*$)/g, ""); 
    }
 
    
    
// A string with spaces in it 
    var s = "    leading and trailing spaces    "
    
    
// Remove the leading and trailing spaces 
    s = s.trim(); 
</script>
posted on 2007-10-16 19:48  Sady  阅读(152)  评论(0)    收藏  举报
凭飞堂