Created
August 5, 2015 00:38
-
-
Save JavaScript-Packer/a1e9d7bd12076e6e1503 to your computer and use it in GitHub Desktop.
Left trimming, right trimmer and trim both sides. Simple demos in JavaScript that replace triml, trimr and trim functions. Escape is used just so you can see the spaces as %20 and makes the changes more obvious.
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
| alert(escape(" trim left "["replace"](/^\s\s*/, ""))); | |
| alert(escape(" trim right "["replace"](/\s\s*$/, ""))); | |
| alert(escape(" trim both "[$ = "replace"](/^\s\s*/, "")[$](/\s\s*$/, ""))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment