regex比较两个数字 [英] regex compare two numbers
本文介绍了regex比较两个数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在某种程度上比较regex中的两个数字?
我想要的regex是正确的10-12,但不正确的12-10。我的意思是10必须小于12.
我想在Javascript中执行。
can i somehow compare two numbers in regex? i want regex that is correct for 10-12, but incorrect for 12-10. I mean that 10 must be smaller than 12. I want to do it in Javascript.
推荐答案
总是使用XY形式,那么为什么不使用带有' - '作为分隔符的split()函数,然后用>
If the input is always of the form X-Y, then why not use the split() function with '-' as the delimiter and then compare the two parts with >
使用RegExps比较数值。
You can't compare numerical values using RegExps.
这篇关于regex比较两个数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文