How to Extract Domain from URLs in Google Sheets?
Extract Domain from URLs is a Google Sheets function that extracts the domain name from a given url or email address.. Formula Genius generates and validates this formula automatically from a plain-English prompt.
Struggling to isolate domains from a list of URLs or email addresses? Use REGEXEXTRACT to simplify your data extraction process.
The Formula
"Extract the domain from a column of URLs or email addresses using REGEXEXTRACT in Google Sheets"
=REGEXEXTRACT(A1, "(?:https?://)?(?:www\.)?([^/]+)")
This formula extracts the domain name from a given URL or email address.
Step-by-Step Breakdown
- The REGEXEXTRACT function is used to apply a regular expression to the input.
- The pattern matches optional 'http://' or 'https://' and 'www.' prefixes.
- The capturing group '([^/]+)' captures the domain name until the next '/' or end of string.
- The formula can be dragged down to apply to multiple rows of data.
Edge Cases & Warnings
- URLs without 'http://' or 'https://' will still be processed correctly.
- Email addresses will return the domain part after '@'.
- Subdomains will be included in the extracted domain.
- URLs with no domain (e.g., 'http://') will return an error.
Examples
"https://www.example.com/path"
example.com
"user@example.org"
example.org
Frequently Asked Questions
Can this formula extract domains from email addresses?
Yes, it extracts the domain part after '@'.
What happens if the URL is malformed?
The formula may return an error or an empty string.
Can I modify the regex to include subdomains?
Yes, the regex can be adjusted to capture subdomains as needed.
Can't find what you need?
Describe any formula in plain English and Formula Genius will generate, explain, and validate it — instantly.