I am using https://regex101.com/ to test my below regular expression but this expression is allowing < character which is not mentioned in the expression.
['!@#$%*\]\[()-=_+{}:\";?,.\/A-Za-z0-9\s]
答案 0 :(得分:8)
-
denotes a range inside a character class.
The range you're matching in your regex is all the characters that appear between ")" and "=", because:
['!@#$%*\]\[()-=_+{}:\";?,.\/A-Za-z0-9\s]
↑ ↑
And the "<" sign appears between them (see here):
You need to:
Change to:
['!@#$%*\]\[()=_+{}:\";?,.\/A-Za-z0-9\s-]
Simpler example:
[1-9]
matches digits from "1" to "9", while:
[19-]
and
[1\-9]
matches "1", "9" and "-".