我使用以下模式进行货币验证。
/(?:^\d{1,3}(?:\.?\d{3})*(?:,\d{2})?$)|(?:^\d{1,3}(?:,?\d{3})*(?:\.\d{2})?$)/
验证哪个:987,654,321.00
我需要一种模式来验证
之类的印度数字系统98,76,54,321.00
我想允许用户输入逗号和一个点。
我没有什么条件。
98,76,54,321.00
,但不能验证987,654,321.00
我已经引用了以下链接Duplicate,但不满足我的要求。我需要帮助以获取准确的模式
谢谢,
卡尔提克答案 0 :(得分:2)
基于示例和注释:
^(?:\d+|\d{1,2},(?:\d{2},)*\d{3})(?:\.\d{2})?$
JavaScript测试代码段:
const reIndianCurry = /^(?:\d+|\d{1,2},(?:\d{2},)*\d{3})(?:\.\d{2})?$/;
console.log('-- Should Match:')
let arr = ['0.00', '123.00', '1,234.12', '12,34,56,789.00', '12,34,567', '123456', '12345.00'];
arr.forEach(function(s){console.log(reIndianCurry.test(s)+' : '+s)});
console.log('-- Should Not Match:')
arr = ['12,345,678.12', '12,34.00'];
arr.forEach(function(s){console.log(reIndianCurry.test(s)+' : '+s)});