简体   繁体   English

正则表达式Javascript数字逗号分隔| > | > = <=

[英]Regex Javascript Numbers Comma Separated | > | >= <=

I'm using this Regex to validate numbers with decimals (comma separated) 我正在使用此正则表达式来验证带小数的数字(逗号分隔)

/(^\d*\,?\d*[1-9]+\d*$)|(^[1-9]+\d*\,\d*$)/

but i need to change it so that it can also validate numbers higher than 5000 and between 3000 and 1000000 但我需要更改它,以便它也可以验证大于5000且介于3000和1000000之间的数字

I'm not a Regex expert even though i have read several tutorials i'm still unable to find a solution...any help is appreciated. 尽管我已经阅读了几本教程,但我仍然不是Regex专家,但我仍然找不到解决方案...任何帮助,我们感激不尽。 thanks in advance. 提前致谢。

This will match numbers between 3000 and 1000000, inclusive, allowing an optional fractional part separated by a coma: 这将匹配3000到1000000(含)之间的数字,并允许用逗号分隔的可选小数部分:

 /^([3-9][0-9]{3}(,[0-9]+)?|[1-9][0-9]{4,5}(,[0-9]+)?|1000000)$/

You can test it here . 您可以在这里进行测试。

This will match numbers greater or equal to 5000, allowing an optional fractional part separated by a coma: 这将匹配大于或等于5000的数字,从而允许用逗号分隔可选的小数部分:

 /^([5-9][0-9]{3}|[1-9][0-9]{4,})(,[0-9]+)?$/

You can test it here . 您可以在这里进行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM