Validate negative and positive decimal numbers with RegEx

后端 未结 5 889
滥情空心
滥情空心 2020-12-09 23:39

I am trying to build a regex which will allow both negative and positive decimal numbers with the following rules.

  1. there can not be more than 2 digits after de
5条回答
  •  醉酒成梦
    2020-12-09 23:55

    My own regex:

    var rgx = /^(-{1}?(?:([0-9]{0,10}))|([0-9]{1})?(?:([0-9]{0,9})))?(?:\.([0-9]{0,3}))?$/;
    

提交回复
热议问题