简体   繁体   English

无法替换[]和; 在上传文件的文件名中

[英]Can't replace [] and ; in filename of the file uploaded

refName = function () {
    var fileName = document.getElementById('import').value;

    fileName = fileName.replace(/[&\/#,+()[];$~%@^'":*?<>{}]/g, '');
    var str = fileName.split("\\"); //to strip path from filename
}

I am passing the file name of the file uploaded to the above function i am able to remove all the Regex except [] and ; 我正在传递上传到上述功能的文件的文件名,我可以删除除[]和;之外的所有正则表达式。 from file name, any help appreciated 从文件名,任何帮助表示赞赏

Try instead: 请尝试:

result = subject.replace(/[&\/#,+()[\];$~%@^'":*?<>{}]/g, "");

The special chars [ , ] are needed to be escaped. 需要转义特殊字符[]

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

相关问题 CKEditor:图像已上传,但仍收到警告说无法上传文件:文件名(使用 ckfinder)在反应 - CKEditor: Image uploaded but still getting an alert saying can't upload file:filename (using ckfinder) in react 我如何获取使用 shiny 文件输入上传的文件的文件名? - Ηow can I get the filename of a file uploaded with a shiny fileInput? 无法移动/优化APC上传的文件 - Can't move/fine APC Uploaded file 获取文件扩展名但无法获取文件名 - Get the extension of a file but can't get the filename 替换DIV内容Javascript,无法正确获取外部文件名 - Replace DIV content Javascript, can't get the external filename right 获取通过ajax上传的文件的文件名 - get filename of file uploaded through ajax 允许上传具有特定文件名和扩展名的文件 - allow file with a specific filename and extension to be uploaded 如何以方形空间形式提醒上传文件的文件名? - how to alert filename of uploaded file in squarespace form? Firebase函数更改存储中上载文件的fileName - Firebase functions change fileName for uploaded file in storage 无法使用API​​在Google云端硬盘中打开上传的文件 - Can't open uploaded file in Google Drive using API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM