正则表达式Javascript数字逗号分隔| > | > =< = [英] Regex Javascript Numbers Comma Separated | > | >= <=

查看:137
本文介绍了正则表达式Javascript数字逗号分隔| > | > =< =的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此正则表达式来验证带小数的数字(逗号分隔)

I'm using this Regex to validate numbers with decimals (comma separated)

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

但是我需要更改它,以便它也可以验证大于5000且介于3000和1000000之间的数字

but i need to change it so that it can also validate numbers higher than 5000 and between 3000 and 1000000

即使我已经阅读了几本教程,但我仍然不是Regex专家,但是我仍然找不到解决方案...感谢您的帮助.预先感谢.

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. thanks in advance.

推荐答案

这将匹配3000到1000000(含)之间的数字,并允许用逗号分隔的可选小数部分:

This will match numbers between 3000 and 1000000, inclusive, allowing an optional fractional part separated by a coma:

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

您可以对其进行测试这将匹配大于或等于5000的数字,从而允许用逗号分隔可选的小数部分:

This will match numbers greater or equal to 5000, allowing an optional fractional part separated by a coma:

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

您可以测试 查看全文

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