Definition Group(?(DEFINE)(?<cons>\b(?:
(?<x>\d*)
(?:(?<a0>0)|(?<a1>1)|(?<a2>2)|(?<a3>3)|(?<a4>4)
|(?<a5>5)|(?<a6>6)|(?<a7>7)|(?<a8>8))
(?:9(?= 9*,\g{x}\d (?<y>\g{y}?+ 0)))*
,\g{x}
(?(a0)1)(?(a1)2)(?(a2)3)(?(a3)4)(?(a4)5)
(?(a5)6)(?(a6)7)(?(a7)8)(?(a8)9)
(?(y)\g{y})
# handle the 999 => 1000 case separately
| (?:9(?= 9*,1 (?<z>\g{z}?+ 0)))+
,1\g{z}
)\b)) Group cons(?<cons>\b(?:
(?<x>\d*)
(?:(?<a0>0)|(?<a1>1)|(?<a2>2)|(?<a3>3)|(?<a4>4)
|(?<a5>5)|(?<a6>6)|(?<a7>7)|(?<a8>8))
(?:9(?= 9*,\g{x}\d (?<y>\g{y}?+ 0)))*
,\g{x}
(?(a0)1)(?(a1)2)(?(a2)3)(?(a3)4)(?(a4)5)
(?(a5)6)(?(a6)7)(?(a7)8)(?(a8)9)
(?(y)\g{y})
# handle the 999 => 1000 case separately
| (?:9(?= 9*,1 (?<z>\g{z}?+ 0)))+
,1\g{z}
)\b) \ban ASCII word boundary
Non-Capturing Group(?:
(?<x>\d*)
(?:(?<a0>0)|(?<a1>1)|(?<a2>2)|(?<a3>3)|(?<a4>4)
|(?<a5>5)|(?<a6>6)|(?<a7>7)|(?<a8>8))
(?:9(?= 9*,\g{x}\d (?<y>\g{y}?+ 0)))*
,\g{x}
(?(a0)1)(?(a1)2)(?(a2)3)(?(a3)4)(?(a4)5)
(?(a5)6)(?(a6)7)(?(a7)8)(?(a8)9)
(?(y)\g{y})
# handle the 999 => 1000 case separately
| (?:9(?= 9*,1 (?<z>\g{z}?+ 0)))+
,1\g{z}
) 1st Alternative
(?<x>\d*)
(?:(?<a0>0)|(?<a1>1)|(?<a2>2)|(?<a3>3)|(?<a4>4)
|(?<a5>5)|(?<a6>6)|(?<a7>7)|(?<a8>8))
(?:9(?= 9*,\g{x}\d (?<y>\g{y}?+ 0)))*
,\g{x}
(?(a0)1)(?(a1)2)(?(a2)3)(?(a3)4)(?(a4)5)
(?(a5)6)(?(a6)7)(?(a7)8)(?(a8)9)
(?(y)\g{y})
# handle the 999 => 1000 case separately
\d*a digit, repeated any number of times
Non-Capturing Group(?:(?<a0>0)|(?<a1>1)|(?<a2>2)|(?<a3>3)|(?<a4>4)
|(?<a5>5)|(?<a6>6)|(?<a7>7)|(?<a8>8)) 0the literal 0 (4810 / 608 / 3016)
1the literal 1 (4910 / 618 / 3116)
2the literal 2 (5010 / 628 / 3216)
3the literal 3 (5110 / 638 / 3316)
4the literal 4 (5210 / 648 / 3416)
5the literal 5 (5310 / 658 / 3516)
6the literal 6 (5410 / 668 / 3616)
7the literal 7 (5510 / 678 / 3716)
8the literal 8 (5610 / 708 / 3816)
Non-Capturing Group(?:9(?= 9*,\g{x}\d (?<y>\g{y}?+ 0)))* *repeats the group contents below any number of times:
9the literal 9 (5710 / 718 / 3916)
Positive Lookahead(?= 9*,\g{x}\d (?<y>\g{y}?+ 0))
,the literal text ,
\g{x}the text saved by group x
Comment: handle the 999 => 1000 case separately
2nd Alternative (?:9(?= 9*,1 (?<z>\g{z}?+ 0)))+
,1\g{z}
\ban ASCII word boundary
Comment: list of two or more consecutive integers
Positive Lookahead(?=(?&cons)) \d+a digit, repeated at least once
Non-Capturing Group(?:,(?=(?&cons))\d+)* \d+a digit, repeated at least once
g modifier: global. Finds all matches instead of stopping after the first
x modifier: extended. Ignores unescaped whitespace and comments outside character classes