Regular expression for 7 digits not starting with 0 or 1

前端 未结 2 1623
臣服心动
臣服心动 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

    0 讨论(0)
  • 2021-01-14 09:01

    You can try this:

    ^[2-9][0-9]{6}$
    
    0 讨论(0)
提交回复
热议问题