Created
May 13, 2011 16:31
-
-
Save eralston/970842 to your computer and use it in GitHub Desktop.
JavaScript snippet for trimming whitespace from strings - http://www.somacon.com/p355.php
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
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+$/,""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment