Re: SELECT using RegEx inside a POSITION function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Danny Stewart" <dstewart(at)pcfa(dot)org>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: SELECT using RegEx inside a POSITION function
Date: 2003-04-26 16:26:02
Message-ID: 9082.1051374362@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Danny Stewart" <dstewart(at)pcfa(dot)org> writes:
> I am trying to use
> SELECT substring(id from position(~ '[0-9]' in id)) FROM resources ;
> but that returns:
> Unable to identify a prefix operator '~' for type 'unknown'

I think you are mixing up substring() and position(). If I understand
your problem correctly, what you need is just the regex-style substring
function:

regression=# select substring('Folder 567 Section 6' from '[0-9]+');
substring
-----------
567
(1 row)

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Bruno Wolff III 2003-04-26 18:18:08 Re: Date format errors
Previous Message Tom Lane 2003-04-26 16:10:54 Re: implicit lock in RULE ?