Created
August 29, 2013 12:30
-
-
Save guigmaster/6377456 to your computer and use it in GitHub Desktop.
Implementation of the function to trim the string object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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