正则表达式能否区分JavaScript中包含每个子句长度恒定数的字符串?
对不起,我的英语很差。以下是一些例子:正则表达式能否区分JavaScript中包含每个子句长度恒定数的字符串?,javascript,regex,Javascript,Regex,对不起,我的英语很差。以下是一些例子: '000,111,123,486' //true '000' //true '000,111,123,486,781' //true '000,111,123,486,781,471' //true '868,1,662' //false because the length of the second clause is 1. '000,' //false because there is only 1 clause so the comma is no
'000,111,123,486' //true
'000' //true
'000,111,123,486,781' //true
'000,111,123,486,781,471' //true
'868,1,662' //false because the length of the second clause is 1.
'000,' //false because there is only 1 clause so the comma is not allowed.
我需要一个正则表达式来匹配这个模式。谢谢。我自己解决了
/^(\d{3})(,\d{3})*$/