Thread: BUG #8679: Error in regex function

BUG #8679: Error in regex function

From
spmpro@pochta.ru
Date:
The following bug has been logged on the website:

Bug reference:      8679
Logged by:          Andrzej
Email address:      spmpro@pochta.ru
PostgreSQL version: 9.2.0
Operating system:   Ubuntu
Description:

Hi, I make command select regexp_replace('rewqe ','(?<=[q]{1})[e]{1}(?=[\-
$]+)','11');
and he return error 'invalid regular expression: quantifier operand
invalid', but regex is correct (check by http://gskinner.com/RegExr/). This
error repeat in another regex function (regexp_matches,
regexp_split_to_array).


But command select regexp_replace('rewqe ','[e]{1}(?=[\- $]+)','11') work
good. May be, regex construction (?<=\pattern\) is not support?

Re: BUG #8679: Error in regex function

From
Tom Lane
Date:
spmpro@pochta.ru writes:
> May be, regex construction (?<=\pattern\) is not support?

It is not.  What we support is documented at
http://www.postgresql.org/docs/9.2/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP

I have no idea what "(?<=" is supposed to mean --- it's not a standard
regexp construct, for sure.  In general, "(?" is used to introduce
non-POSIX extensions that are specific to particular regexp
implementations.  There's some commonality there, but you should never
assume that such things are portable.

            regards, tom lane

Re: BUG #8679: Error in regex function

From
"Erik Rijkers"
Date:
On Fri, December 13, 2013 18:40, Tom Lane wrote:
> spmpro@pochta.ru writes:
>> May be, regex construction (?<=\pattern\) is not support?
>
> It is not.  What we support is documented at
> http://www.postgresql.org/docs/9.2/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP
>
> I have no idea what "(?<=" is supposed to mean --- it's not a standard

FWIW, perl has these; see http://perldoc.perl.org/perlre.html (search for "Look-Around Assertions" ):

   (?<=pattern)   A zero-width positive look-behind assertion

   (?<!pattern)   A zero-width negative look-behind assertion.


It would certainly be nice if these would implemented in postgres...