Created
March 23, 2012 22:55
-
-
Save scodx/2176070 to your computer and use it in GitHub Desktop.
trim in JavaScript
This file contains hidden or 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
| /** | |
| * Set of funcitons that trims a string in Javascipt :) | |
| **/ | |
| function trim(stringToTrim) { | |
| return stringToTrim.replace(/^\s+|\s+$/g,""); | |
| } | |
| function ltrim(stringToTrim) { | |
| return stringToTrim.replace(/^\s+/,""); | |
| } | |
| function rtrim(stringToTrim) { | |
| return stringToTrim.replace(/\s+$/,""); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment