正则表达式匹配两个或多个逗号分隔的整数

Regex to match two or more comma separated integers

我有一个逗号分隔值列表:

123            should fail   // using my regex this pass 
123, 230       should pass
234, 560, 890  should pass

使用这个正则表达式 ^(\d+(, \d+)*)?$ 如果它是单个值,它仍然通过。

如何才能只匹配列表中的 2 个或更多整数?

* 更改为 +* 表示 0 个或多个匹配项,+ 表示 1 个或多个匹配项。

您应该使用 + 而不是 * 以确保 [=13th=] 部分至少存在 1 次。

^(\d+(, \d+)+)?

检查这个:
https://regex101.com/r/yvWiZ0/1