Skip to content

Instantly share code, notes, and snippets.

@guigmaster
Created August 29, 2013 12:30
Show Gist options
  • Save guigmaster/6377456 to your computer and use it in GitHub Desktop.
Save guigmaster/6377456 to your computer and use it in GitHub Desktop.
Implementation of the function to trim the string object
//trim completo
String.prototype.trim = function () {
return this.replace(/^\s+|\s+$/g,"");
}
//left trim
String.prototype.ltrim = function () {
return this.replace(/^\s+/,"");
}
//right trim
String.prototype.rtrim = function () {
return this.replace(/\s+$/,"");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment