Why is this regex allowing a caret?

前端 未结 3 1847
鱼传尺愫
鱼传尺愫 2020-11-21 05:34

http://regexr.com/3ars8

^(?=.*[0-9])(?=.*[A-z])[0-9A-z-]{17}$

Should match \"17 alphanumeric chars, hyphens allowed too, must include at le

3条回答
  •  日久生厌
    2020-11-21 06:10

    You're allowing A-z (capital 'A' through lower 'z'). You don't say what regex package you're using, but it's not necessarily clear that A-Z and a-z are contiguous; there could be other characters in between. Try this instead:

    ^(?=.*[0-9])(?=.*[A-Za-z])[0-9A-Za-z-]{17}$
    

    It seems to meet your criteria for me in regexpal.

提交回复
热议问题