我有一个文件,我需要对此进行一些正则表达式验证。
验证是文件名只能包含ASCII 32-126个字符,
除了:–34 ["] –39 [’] –59 [;] –60 [<] –61 [=] –62 [>] –92 [\]
此外,文件名不能包含以下字符序列:–%00
let filename = "filename"
let regex = ""
console.log(filename);
有人可以看看让我知道解决方法吗? 谢谢
答案 0 :(得分:3)
您可以使用以下正则表达式:
^(?:(?!["';<=>\\])[\x20-\x7E])+$
说明:
^ # start of line
(?: # non-capturing group
(?!["';<=>\\]) # negative lookahead - do not to match if contains given symbols
[\x20-\x7E] # match in range from ASCII 32-126
) # close non-capturing group
+ # match 1-unlimited times
$ # end of line