繁体   English   中英

正则表达式从Windows的文件名中删除特殊字符

[英]Regular expression remove the special character from a file name for Windows

http://msdn.microsoft.com/zh-cn/library/windows/desktop/aa365247(v=vs.85).aspx中 ,我们知道Windows保留了一些字符:

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

我有一个包含这些特殊字符的文件名,我想用“”替换那些,像这样(string.replace(/ \\ <> / g,'')
谢谢

您可以将所有这些字符放在一个字符集中:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM