验证正则表达式是否具有百分位数和无百分位数...? [英] Validation Regex for quantities with centesimal and without centesimal ...?

查看:109
本文介绍了验证正则表达式是否具有百分位数和无百分位数...?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

向社区问好,我有一个查询,我需要一个正则表达式验证,对于没有小数的金额,它认为以下结构有效.

Hello to the community I have a query, I need a validation Regex, for amounts without decimals, that consider valid the following structure.

99,999,999

如果我添加一个值:

12345678        -> Ok
12,345,678      -> Ok   
123,456,789     -> Failed
123,45,6,78     -> Failed
12,345,678.50   -> Failed
12,456,7ab      -> Failed

我只能验证8个数字字符的大小:

I have only been able to validate the size of 8 numerical characters:

var regex8 = /^-?([0-9]{1,8})?$/;

我在等你的评论.

谢谢.

推荐答案

通过一些工作,您可以制作一个模式来做到这一点:

With a bit of work you can craft a pattern to do this:

https://regex101.com/r/DKpSUR/1

/^-?([0-9]{1,2},?)?([0-9]{3},?){1,2}$/

这篇关于验证正则表达式是否具有百分位数和无百分位数...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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