RegEx - Exclude zero

前端 未结 6 531
抹茶落季
抹茶落季 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 01:07

    If I understand your requirement, use [1-9] in place of [0-9] or \d:

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

提交回复
热议问题