Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Community Library
How to contribute
x
ipv4 and ipv6 with mask in CIDR
Open Workspace
PCRE2 (PHP)
Match
Created 2023-10-11 20:04
1
Regular Expression
/
\b
(
(?:
(?:
25
[
0
-
5
]
|
2
[
0
-
4
]
[
0
-
9
]
|
[
01
]
?
[
0
-
9
]
[
0
-
9
]
?
)
\.
){3}(?:
25
[
0
-
5
]
|
2
[
0
-
4
]
[
0
-
9
]
|
[
01
]
?
[
0
-
9
]
[
0
-
9
]
?
)+(?:
\/
{1}
(
(?:
[
0
-
9
]
)
|
(?:
[
1
-
2
]
[
0
-
9
]
)
|
(?:
3
[
0
-
2
]
)
)
\b
)?
)
|
(
(?:
[
a
-
f0
-
9:
]
+
:
+
)+(?:
[
a
-
f0
-
9
]
)+(?:
\/
{1}
(
(?:
(?:
3
[
0
-
2
]
|
[
12
]
?
\d
)
)
)
\b
)?
)
/
gm
Description
Match and validate both ipv4, ipv6 and CIDR notation mask!
Submitted by
Stefanos Mitropoulos