Because your character class [A-z]
matches this symbol.
[A-z]
matches [
,
, ]
, ^
, _
, `
, and the English letters.
Actually, it is a common mistake. You should use [a-zA-Z]
instead to only allow English letters.
Here is a visualization from Expresso, showing what the range [A-z]
actually covers:
So, this regex (with i
option) won't capture your string.
^(?=.*[0-9])(?=.*[a-z])[0-9a-z-]{17}$
In my opinion, it is always safer to use Ignorecase
option to avoid such an issue and shorten the regex.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…