`

js去空格

阅读更多
//为String对象添加Trim,LTrim,RTrim方法  
//去左右空格  
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, "");  
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics