Re: Why this regexp matches?! - Mailing list pgsql-general

From Alban Hertroys
Subject Re: Why this regexp matches?!
Date
Msg-id 5F2D84C1-179A-42BA-A5F9-F338B93E8AD7@gmail.com
Whole thread Raw
In response to Why this regexp matches?!  (hubert depesz lubaczewski <depesz@depesz.com>)
Responses Re: Why this regexp matches?!
Re: Why this regexp matches?!
List pgsql-general
On 4 Feb 2012, at 9:46, hubert depesz lubaczewski wrote:

> select 'depesz depeszx depesz' ~ E'^(.*)( \\1)+$';

Peculiar.

It's probably no use to you, but a version where the repetition is expanded (for that particular string) works:

select 'depesz depeszx depesz' ~ E'^(.*)( \\1)( \\1)$';

And this works too:

select 'depesz depeszx depesz' ~ E'^(depesz)( \\1)+$';

Apparently something odd is going on between the wildcard, the repetitive part and the back-reference. That could be
justus not seeing what's wrong with the expression or be an actual bug. 

> I know that Pg regexps are limited, but even grep's regexps match this

Limited? They're really not. According to the docs they are beyond POSIX compliant, even including several extensions
asthey appear in, among others, Perl. That said, the docs do mention a known limitation with braces and
forward-references- maybe this is related. 

Alban Hertroys

--
The scale of a problem often equals the size of an ego.



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: debugging the server[ module causes server cash]
Next
From: hubert depesz lubaczewski
Date:
Subject: Re: Why this regexp matches?!