Getting domain name from string

Can I ask help with getting domain name from string please ?
For ex:
for I want
for I want
for * I want

In short, regardless of how deep is the domain, i want to get


Is it always going to be a type domain, or could it also be things like

The @stuart-c . Thanks for replying. It could be anything like, or

Then, you cannot do this via purely algorithmic string processing.

You need to refer to the Public Suffix List:

Data processing of this complexity is best performed in you own custom code before you invoke Terraform - then feed Terraform the processed data via variables or JSON/YAML files.

1 Like