Extract TLD

This function extracts the top-level domain from a URL. This function will use the public suffix list to extract the TLD. Check the Extracting The Main Domain section for more information about the public suffix list.

D SELECT extract_tld('https://example.com.ac/path/path') AS tld;
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   tld   β”‚
β”‚ varchar β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ com.ac  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

D SELECT extract_tld('a.example.com') AS tld;
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   tld   β”‚
β”‚ varchar β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ com     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Last updated

Was this helpful?