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
/
^(?=(?:\D*\d){8}$)\d+(?:(?:-\d+){0,2}|(?:\s+\d+){0,1})$
/
gm
Input 1
1
New
12345678 1234 5678 1234-5678 123-45-678 12-345-678 It should not accept these examples: 1234 123456789 -12345678- !@@#$% 12ABCBDEF 12-34-56-78
Substitution
12345678 1234 5678 1234-5678 123-45-678 12-345-678 It should not accept these examples: 1234 123456789 -12345678- !@@#$% 12ABCBDEF 12-34-56-78