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
/
^(?:(?:[1-9]?[0-9]|1[0-9][0-9]|2(?:[0-4][0-9]|5[0-5]))\.){3}(?:[1-9]?[0-9]|1[0-9][0-9]|2(?:[0-4][0-9]|5[0-5]))(?:\/(?:[12]?[0-9]|3[0-2]))?$
/
Unit Tests
172.0.0.1/16
→ regex does match
0.0.0.0
→ regex does match
255.255.255.255
→ regex does match
1.9.10.19
→ regex does match
29.99.199.249
→ regex does match
100.190.200.209
→ regex does match
210.249.250.255
→ regex does match
0.0.0.0/33
→ regex does not match
00.01.00.09
→ regex does not match
0.0.0.0/00
→ regex does not match
0.0.0
→ regex does not match
0.0.0.0.0
→ regex does not match
0/0/0/0
→ regex does not match
0_0_0_0
→ regex does not match
0'0'0'0
→ regex does not match