Extracting hostname from URI column

Поиск
Список
Период
Сортировка
От ogjunk-pgjedan@yahoo.com
Тема Extracting hostname from URI column
Дата
Msg-id 335284.57764.qm@web50301.mail.re2.yahoo.com
обсуждение исходный текст
Ответы Re: Extracting hostname from URI column  (chester c young <chestercyoung@yahoo.com>)
Re: Extracting hostname from URI column  (Paul Lambert <paul.lambert@autoledgers.com.au>)
Список pgsql-sql
Hi,

I'm trying to use substr() and position() functions to extract the full host name (and later a domain) from a column
thatholds URLs. 
This is what I'm trying, but it clearly doesn't do the job.

=> select substr(href, position('://' in href)+3, position('://' in href)+3+position('/' in href)), href from url where
id<10;    substr     |                           href 
----------------+----------------------------------------------------------texturizer.net |
http://texturizer.net/firebird/extensions/texturizer.net| http://texturizer.net/firebird/themes/forums.mozilla |
http://forums.mozillazine.org/index.php?c=4www.mozillazin| http://www.mozillazine.org/devedge.netsca |
http://devedge.netscape.com/viewsource/2002/bookmarks/www.google.com| http://www.google.com/search?&q=%sgroups.google.
|http://groups.google.com/groups?scoring=d&q=%swww.google.com |
http://www.google.com/search?q=%s&btnI=I'm+Feeling+Luckydictionary.ref| http://dictionary.reference.com/search?q=%s 

The 3rd param to the substr function is clearly wrong.  Is it even doable without writing a procedure?

Finally, is this the fastest way to get this data, or is there  regex-based function that might be faster?

Thanks,
Otis




В списке pgsql-sql по дате отправления:

Предыдущее
От: Richard Broersma Jr
Дата:
Сообщение: Re: Simple Query?
Следующее
От: chester c young
Дата:
Сообщение: Re: Extracting hostname from URI column