Return to Snippet

Revision: 7204
at July 14, 2008 01:31 by donkeykong


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

Initial URL

                                

Initial Description
sample:
var text = "    string content    ";

text = text.trim();

Initial Title
javascript string methods

Initial Tags
javascript

Initial Language
JavaScript