url_extract_port

url

Extracts the port number from a URL

Syntax

url_extract_port(url)

Parameters

url (string)

The URL string to extract the port from

Returns

number

The port number, or null if using default port

Examples

Input:
url_extract_port("https://example.com:8080")
Output:
8080
Input:
url_extract_port("https://example.com")
Output:
null

The url_extract_port() function extracts the port number from a URL. If no explicit port is specified in the URL (meaning it uses the default port for its protocol), the function returns null.

Usage

Use url_extract_port() when you need to identify URLs using non-standard ports, such as finding development servers or non-standard service configurations in logs.