Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
/
(?(DEFINE)(?<cons>\b(?: (?<x>\d*) (?:(?<a0>0)|(?<a1>1)|(?<a2>2)|(?<a3>3)|(?<a4>4) |(?<a5>5)|(?<a6>6)|(?<a7>7)|(?<a8>8)) (?<y> ,\g{x} (?(a0)1)(?(a1)2)(?(a2)3)(?(a3)4)(?(a4)5) (?(a5)6)(?(a6)7)(?(a7)8)(?(a8)9) | 9 (?&y) 0 ) # handle the 999 => 1000 case separately | (?<z> 9,10 | 9(?&z)0 ) )\b)) # list of two or more consecutive integers (?=(?&cons))\d+ (?:,(?=(?&cons))\d+)* ,\d+
/
gx
Input 1
1
New
0,1,2,3 8,9,10,11 1999,2000,2001 99,100,101 42 3,2,1 1,2,4 10,11,13
Substitution
0,1,2,3 8,9,10,11 1999,2000,2001 99,100,101 42 3,2,1 1,2,4 10,11,13