Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
/
^\d{5}(?![\d-])|^\d{5}(?:-\d{4})(?!\d)|(?<!\d)\d{5}(?:-\d{4})(?:[\r\n])|(?<![\d-])\d{5}(?:[\r\n])
/
gm
Input 1
1
New
Nothing to match in the middle 06000 or 06000-0000 on this line 06111 these are ok 06222-1111 06333-1111 and these 06444 06555-333 these are not 06666-444 06777-66666 also not 06888-77777 06888-00001 but this last one is 06999-9999 this should not match 123456-1234 While this one should likely match: 12345
Extraction