admin管理员组文章数量:1375246
From (v=vs.85).aspx, We know Windows reserve some characters:
< (less than)
> (greater than)
: (colon)
" (double quote)
/ (forward slash)
\ (backslash)
| (vertical bar or pipe)
? (question mark)
* (asterisk)
I have a file name which contains e of those special characters,
I want to replace those with "",
something like this (string.replace(/\<>/g, '')
Thanks
From http://msdn.microsoft./en-us/library/windows/desktop/aa365247(v=vs.85).aspx, We know Windows reserve some characters:
< (less than)
> (greater than)
: (colon)
" (double quote)
/ (forward slash)
\ (backslash)
| (vertical bar or pipe)
? (question mark)
* (asterisk)
I have a file name which contains e of those special characters,
I want to replace those with "",
something like this (string.replace(/\<>/g, '')
Thanks
- This is a challenging request as Windows has odd file name rules. See this SO article: stackoverflow./questions/754307/… – jwatts1980 Commented Aug 8, 2014 at 17:39
- thanks, I didn't find it when I google it. Sorry for ask dumplicate question – yongnan Commented Aug 8, 2014 at 17:44
1 Answer
Reset to default 8You can put all those characters inside a character set:
string.replace( /[<>:"\/\\|?*]+/g, '' );
本文标签: javascriptRegular expression remove the special character from a file name for WindowsStack Overflow
版权声明:本文标题:javascript - Regular expression remove the special character from a file name for Windows - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743977064a2570921.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论