From: | Ian Barwick <barwick(at)gmail(dot)com> |
---|---|
To: | joseph speigle <joe(dot)speigle(at)jklh(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: substring syntax with regexp |
Date: | 2004-06-30 15:15:03 |
Message-ID: | 1d581afe04063008154659b285@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, 30 Jun 2004 08:45:18 -0500, joseph speigle <joe(dot)speigle(at)jklh(dot)us> wrote:
> hi,
>
> Does anybody know offhand what is the correct way to use substr to extract the domain name from a client_referer column as logged by mod_pgsqllog (httpd module), by correcting the following:
>
> the file 'hostname.sql' is pl/pgsql
>
> main=> \e hostname.sql
> ERROR: syntax error at or near "http" at character 290
> LINE 13: newuri = substr(tempuri from 'http://[^/]*/.*');
You have several immediate problems with this line:
- your regex should be double-quoted;
- the relevant function is "substring", not "substr";
- the regex pattern you want is probably more like :
'http://([^/]*)/', e.g.
test=> select substring('http://www.example.com/dir/file.html' from
'http://([^/]*)');
substring
-------------
www.example.com
(1 row)
HTH
Ian Barwick
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2004-06-30 15:15:49 | Re: sharing tcl proc's between functions |
Previous Message | Thomas LeBlanc | 2004-06-30 15:14:54 | Running PostgreSQL on Windows 9x/2000/2003... |