Skip site navigation (1) Skip section navigation (2)

Re: substring syntax with regexp

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: (view raw, whole thread or download thread mbox)
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('' from 
(1 row)


Ian Barwick

In response to

pgsql-general by date

Next:From: Tom LaneDate: 2004-06-30 15:15:49
Subject: Re: sharing tcl proc's between functions
Previous:From: Thomas LeBlancDate: 2004-06-30 15:14:54
Subject: Running PostgreSQL on Windows 9x/2000/2003...

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group