Regex: how to only allow integers greater than zero

后端 未结 6 987
失恋的感觉
失恋的感觉 2021-01-20 00:42

I have tried the following to only allow integers in my text box, this works great but it allows a zero in there. Is there anything else I can add to prevent a zero being ad

6条回答
  •  清酒与你
    2021-01-20 01:01

    Code:

    ^([1-9][0-9]+|[1-9])$
    

    Example: http://regexr.com/3annd

    Tested with:

    0
    10
    01
    11
    00
    1
    100
    

提交回复
热议问题