urbansky
5/31/2016 - 12:23 PM

Remove all special characters so a string can be used as valid filename

Remove all special characters so a string can be used as valid filename

// 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