JavaScript去除空格的好方法 (javascript js String trim() )

参考地址:JavaScript去除空格的三种方法 http://www.yaosansi.com/post/304.html

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

String.prototype.trimLeft = function() {
	return this.replace(/(^\s*)/g, "");
}

String.prototype.trimRight = function() {
	return this.replace(/(\s*$)/g, "");
}

你可能感兴趣的:(JavaScript,js,String,prototype,trim())