Skip to content

Instantly share code, notes, and snippets.

@ciaranmahoney
Created August 18, 2016 21:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ciaranmahoney/046a6c1cfd9e12eb37a9adea34a5e7df to your computer and use it in GitHub Desktop.
Save ciaranmahoney/046a6c1cfd9e12eb37a9adea34a5e7df to your computer and use it in GitHub Desktop.
Formula for extracting naked domain from full url in Google Sheets.
=iferror(trim(REGEXEXTRACT(REGEXREPLACE(REGEXREPLACE(A2,"https?://",""),"^(w{3}\.)?","")&"/","([^/?]+)")))
@ihorkit
Copy link

ihorkit commented Nov 11, 2018

thanks for the formula. how would you extract subdomains e.g. "sub.example.com" to "example.com"?

@muthali
Copy link

muthali commented Sep 10, 2020

I was able to get a formula of my own that works with subdomains as well. I have written about it here universal URL to domain google sheets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment