[英]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.