Calculated field for root domain

Hoping for help with this please - Looking for calculated field formula to return root domain only. As example, the following strings should all return “

thanks for any help or insight

if you use athena as a datasource, there are url functions in Presto, that can extract everything from the url.

If you absolutly need it in a calculated field in Quicksight, I would suggest to start with replace and remove every variation of www and https. Then you start with ‘example’ on every line.

Do you have subdomains? So could there be
If not, you could use split after replace on ‘.’ and take the first value.

With subdomains you probably need an ifelse to see, if there are more than 2 elements after split.