Skip to content

Instantly share code, notes, and snippets.

@thirdj
Created January 25, 2013 01:29
Show Gist options
  • Save thirdj/4630783 to your computer and use it in GitHub Desktop.
Save thirdj/4630783 to your computer and use it in GitHub Desktop.
javascript trim, ltrim, rtrim
String.prototype.trim = function() {
return this.replace(/^\s*-,"").replace(/\s*$/, "");
};
String.prototype.ltrim = function() {
return this.replace(/^\s+/, "");
};
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