Regular expression for 7 digits not starting with 0 or 1

前端 未结 2 1624
臣服心动
臣服心动 2021-01-14 08:26

I am trying to accept only 7 digit long number not starting with 0 or 1

7089097 - OK

0089097 - Not good

1089097 - Not good

This is what i tri

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-14 08:44

    This regex will work:

    ^[2-9][0-9]{6}$ 
    

    Out of 7 digits 1 is consumed by first position 2-9 and then next 6 digits can be from 0-9

提交回复
热议问题