RegEx - Exclude zero

前端 未结 6 581
抹茶落季
抹茶落季 2021-01-26 00:21

How can I exclude the 0 input in this regex? The user should be able to enter any number... but not the zero

^([0-9]*|\\d*\\.\\d{1}?\\d*)$

Than

6条回答
  •  悲哀的现实
    2021-01-26 00:55

    This work only with natural numbers to 5 digit and limit five 0 digit at the left (you can personalize that limit)

    /^[0]{0,5}[1-9]\d{0,4}$/
    

    match:

    1
    01 .. 000001
    0100000 .. 0000010000
    

    not match:

    0
    00 .. 00000
    

提交回复
热议问题