Created
May 31, 2016 12:23
-
-
Save urbansky/e68bd4c65e6577d10e1441de1ce90649 to your computer and use it in GitHub Desktop.
Remove all special characters so a string can be used as valid filename
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
// Replace all special characters with empty string | |
var filename = stringToFilter.replace(/[^\w\s\-\.]/gi, '') | |
// ^ Negation | |
// \w alpha numeric | |
// \s spaces | |
// /gi search global and case insensitive |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment