正则表达式允许十进制数大于0且小于100 [英] Regex to allow decimal numbers greater than 0 and less than 100

查看:959
本文介绍了正则表达式允许十进制数大于0且小于100的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图输入大于 0 和小于 100 的值,并使用以下正则表达式:

  / ^(0 +)?(99(\.99?)?|(\.99?)? |。\ [0-9] + | 0 [0-9](\ [0-9] {0,2})|???(0 +)[0-9] [0-9] (\。[0-9] [0-9]?)?)$ / 

this正则表达式不会抱怨零,但0.01是一个有效的值。

基本上,我试图在 00.00 格式,也可以接受像 0.01,00.01,... 99.99 这样的值,但只限于数字和点。



我使用 javascript 的问题和 html 的问题

解决方案

  ^(?! 0?0 \.00 $)\ d {1,2} \.\ d {2} 

您可以ñ简单地使用this.See演示。



https: //regex101.com/r/qB0jV1/10


I am trying to enter value greater than 0 and less than 100 and i am using the following regex:

/^(0+)?(99(\.99?)?|(\.99?)?|\.[0-9]+|0?[0-9](\.[0-9]{0,2})?|(0+)?[0-9][0-9](\.[0-9][0-9]?)?)$/

this regex does not complain about zero but 0.01 is a valid value.

Basically, I am trying to get the value in a 00.00 format and it is also acceptable to have values like 0.01, 00.01, ... 99.99 but strictly numbers and dot only.

I am using and

解决方案

^(?!0?0\.00$)\d{1,2}\.\d{2}$

You can simply use this.See demo.

https://regex101.com/r/qB0jV1/10

这篇关于正则表达式允许十进制数大于0且小于100的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆