How to pattern match a domain name

I am wondering if its possible to use pattern matching in elixir to get the domain name of a website.
For instance:
“www.“domainname”.com”
or
“https://“domainname”.co.uk”
so Domainname might be, “google” or “amazon”

I think it’s not that easy given the various changing list of top-level domains. I’d look around for a package to handle that.

2 Likes

yeah https://hex.pm/ is your friend… searching for domain or tld yields:
domainatrex | Hex which I believe does the job for you;-)

1 Like