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
/
((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:((
/
Unit Tests
fe80:0:0:0:0204:61ff:254.157.241.86
→ regex does match
fe80::204:61ff:254.157.241.86
→ regex does match
fe80:0000:0000:0000:0204:61ff:254.157.24…
→ regex does match
fe80::204:61ff:fe9d:f156
→ regex does match
fe80:0:0:0:204:61ff:fe9d:f156
→ regex does match
fe80:0000:0000:0000:0204:61ff:fe9d:f156
→ regex does match
empty string
→ regex does not match
::1
→ regex does match
fe80::
→ regex does match
2001::
→ regex does match
2a02:a451:76de::/48
→ regex does not match
2001:0db8:85a3:0000:0000:8a2e:0370:7334
→ regex does match
::ffff:10.0.0.1
→ regex does match
1:2:3:4:5:6:77:88
→ regex does match
fe08::7:8
→ regex does match
1:2:3:4:5:6:7:8:9
→ regex does not match
1:2:3:4:5:6:7:8:
→ regex does not match
::1:2:3:4:5:6:7:8
→ regex does not match
1:2:3:4:5:6:7:88888
→ regex does not match
192.168.1.1
→ regex does match
0.0.0.0
→ regex does match
255.255.255.255
→ regex does match
10.0.0.1
→ regex does match
10002.3.4
→ regex does not match
1.2.3.4.5
→ regex does not match
256.0.0.0
→ regex does not match
260.0.0.0
→ regex does not match
fe08::7:8interface
→ regex does not match