Networkingflags: g
Domain Name
Match fully-qualified domain names like example.com or api.sub.example.co.uk.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,} (flags: g)Raw source: (?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}
How it works
Each label is 1–63 characters of letters, digits, or hyphens (not starting or ending with hyphen). One or more labels followed by a TLD of 2+ letters.
Examples
Input
example.comMatches
example.com
Input
api.sub.example.co.ukMatches
api.sub.example.co.uk
Input
not a domainNo match
—Common use cases
- •Extracting domains from email/URLs
- •DNS zone auditing
- •Allowlist / blocklist enforcement
- •Analytics referrer parsing
Related patterns
FTP URL
NetworkingMatch FTP and FTPS URLs, capturing optional credentials, host, port, and path.
Generic Connection String (URL Form)
NetworkingParse generic URL-form connection strings: `protocol://[user[:pass]@]host[:port][/database]`.
Hostname (Single Label, RFC 1123)
NetworkingValidate a single-label hostname per RFC 1123: 1–63 chars, letters/digits/hyphens, can't start or end with hyphen.
HTTP Status Code
NetworkingMatch 3-digit HTTP status codes in the 1xx–5xx range.