Re: substring syntax with regexp
От | Ian Barwick |
---|---|
Тема | Re: substring syntax with regexp |
Дата | |
Msg-id | 1d581afe04063008154659b285@mail.gmail.com обсуждение исходный текст |
Ответ на | substring syntax with regexp (joseph speigle <joe.speigle@jklh.us>) |
Список | pgsql-general |
On Wed, 30 Jun 2004 08:45:18 -0500, joseph speigle <joe.speigle@jklh.us> wrote: > hi, > > Does anybody know offhand what is the correct way to use substr to extract the domain name from a client_referer columnas 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
В списке pgsql-general по дате отправления: