Re: SELECT using RegEx inside a POSITION function - Mailing list pgsql-novice

From Tom Lane
Subject Re: SELECT using RegEx inside a POSITION function
Date
Msg-id 9082.1051374362@sss.pgh.pa.us
Whole thread Raw
In response to SELECT using RegEx inside a POSITION function  ("Danny Stewart" <dstewart@pcfa.org>)
List pgsql-novice
"Danny Stewart" <dstewart@pcfa.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


pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: implicit lock in RULE ?
Next
From: Bruno Wolff III
Date:
Subject: Re: Date format errors