Need a regular expression - disallow all zeros

后端 未结 7 1555
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 14:41

I want to validate a string to meet the following conditions:

  • Must be 6 characters long
  • Only the first character can be alpha-numeric the rest must be
7条回答
  •  庸人自扰
    2020-11-28 15:14

    Just have a negative lookahead like this to disallow all 0s:

    /^(?!0{6})[A-Z0-9][0-9]{5}$/
    

提交回复
热议问题