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