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
Extract port from URL
Open Workspace
PCRE (Legacy)
Match
Created 2015-07-31 16:11
1
Regular Expression
/
(
^
(
[
A
-
Z
]
*
)(
(
:
\/\/
)?
)(
[
A
-
Z
\d
\.
-
]
{2,}
)
\.
(
[
A
-
Z
]
{2,}
)
:
(
\d
{2,5}
)?
)
/
i
Description
Extracts the port from different possible forms of URL
Submitted by
Anonymous