Re: Extracting hostname from URI column

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Paul Lambert" <paul(dot)lambert(at)autoledgers(dot)com(dot)au>
Cc: "sql pgsql" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Extracting hostname from URI column
Date: 2007-09-16 23:18:56
Message-ID: 873axekxlr.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Paul Lambert" <paul(dot)lambert(at)autoledgers(dot)com(dot)au> writes:

> What would be the best way to do something like that? I assume it won't be a
> simple regex like the above due to the country codes on the end of some
> domains. My thought is look at the last portion of the domain, if it's 2
> characters long then assume it's a country code and grab the last three
> sections, if it's not three characters long then assume it's an international
> domain and grab the last two... but that sounds a bit dodgy.

Not all countries break up their national tld space into sections like .co.uk
or .com.au. Canadian domains can be bought directly under .ca like amazon.ca.

I think you'll have to store a specific list of tlds and how deep you want to
look.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Stanislas de Larocque 2007-09-17 07:17:58 Re: Optimize querry sql
Previous Message Paul Lambert 2007-09-16 22:54:53 Re: Extracting hostname from URI column