Regular expression remove special character from filename for Windows

From http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx , We know that Windows reserves some characters:

< (less than)
> (greater than)
: (colon)
" (double quote)
/ (forward slash)
\ (backslash)
| (vertical bar or pipe)
? (question mark)
* (asterisk)

      

I have a filename that contains these special characters, I want to replace those with "" with something like this (string.replace (/ \ <> / g, '')
Thanks

+3


source to share


1 answer


You can put all of these characters into a character set:



string.replace( /[<>:"\/\\|?*]+/g, '' );

      

+3


source







All Articles