Keep subdomains
=REGEXEXTRACT(A2,"^(?:https?://)?([^/]+)")Keeps www or another subdomain.
Turn a full URL into a clean hostname without the protocol, path or query string.
Turn a full URL into a clean hostname without the protocol, path or query string. Use =REGEXEXTRACT(A2,"^(?:https?://)?(?:www\.)?([^/]+)"), then replace the sample ranges with the columns in your sheet.
The captured group stops at the first slash after the hostname.
| A | |
|---|---|
| 1 | URL |
| 2 | |
| 3 | |
| 4 |
=REGEXEXTRACT(A2,"^(?:https?://)?([^/]+)")Keeps www or another subdomain.
=REGEXREPLACE(REGEXEXTRACT(A2,"^(?:https?://)?([^/]+)"),"^www\.","")Keeps other subdomains.
=ARRAYFORMULA(IF(A2:A="","",REGEXEXTRACT(A2:A,"^(?:https?://)?(?:www\.)?([^/]+)")))Applies the extraction down the column.
Wrap the source in TRIM.
Extend the opening pattern when mailto or ftp inputs are expected.
Wrap the source in TRIM.
Extend the opening pattern when mailto or ftp inputs are expected.
Send this recipe to the SheetSteps assistant and describe how your columns are arranged.