js 去除空格正则

String.prototype.trim = trim;
function trim(){
    var s = this.replace(/^丂+|丂+$/g, "");
    //return this.replace(/^\s+|\s+$/g, "");
    return s.replace(/^\s+|\s+$/g, "");
}

你可能感兴趣的:(js 去除空格正则)