正则表达式为0-10个数字,带有两个小数点 [英] Regex expression for 0-10 numbers with two decimal points
本文介绍了正则表达式为0-10个数字,带有两个小数点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以帮助我使用0到10之间任意数字的正则表达式,最多2位小数
有效数字:
0.23
1.02
6.2
7.20
10.00
10
数字无效:
10.01
12.333
0.233
请帮助
解决方案
这将有效:
^(10 | \\ \)(\.\d {1,2})?
(10 | \d)允许一个数字或10
(\.\d {1,2})?可能的小数后跟1或2位数
尝试:
^((1 \d)|(\d ))(\(\d\d)|。\d){0,1}
Can anyone help me with the regular expression for any number from 0 - 10 with maximum of 2 decimal
Valid numbers:
0.23
1.02
6.2
7.20
10.00
10
Invalid numbers:
10.01
12.333
0.233
Please help
解决方案
This will work:
^(10|\d)(\.\d{1,2})?
(10|\d) allows for a single digit or 10
(\.\d{1,2})? possible decimal followed by 1 or 2 digits
Try:
^((1\d)|(\d))(\.(\d\d)|\d){0,1}
这篇关于正则表达式为0-10个数字,带有两个小数点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文