Created
June 19, 2010 18:54
-
-
Save premasagar/445169 to your computer and use it in GitHub Desktop.
Fast, complete JavaScript trim
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
function trim(str){ | |
return str.replace(/^[\0\t\n\v\f\r\s]+|[\0\t\n\v\f\r\s]+$/g, ''); // match the full set of whitespace characters | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment