正则表达式温度验证 [英] Regex temperature validation
本文介绍了正则表达式温度验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
正则表达式中的温度验证如何?温度可以是整数和十进制,但不能是文本.我没有设置任何位数的限制,因为它既可以是整数,也可以是十进制.
How will the temperature validation in regex be ? The temperature could be both integer and decimal but not text. I am not setting any limits of how many digits, simple as it could be both integer and decimal.
这是XX,XX格式的正则表达式:
This is the regex for XX,XX format:
'regex:/[\d]{2},[\d]{2}/'
推荐答案
您可以执行此操作,它与XX和XX,XX匹配','
任一侧上任意数量的数字:
You could do this, it matches XX and XX,XX for any number of digits on either side of ','
:
'regex:/[\d]*,?[\d]*/'
(可选)您也可以对单位执行此操作:(132.0 C) or (32.0000 F) or (32. K)
Optionally, you can do this for the units as well: (132.0 C) or (32.0000 F) or (32. K)
'regex:/[\d]*,?[\d]* [CFK]/'
这篇关于正则表达式温度验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文