Re: regexp_matches() quantified-capturing-parentheses oddity

From: Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: regexp_matches() quantified-capturing-parentheses oddity
Date: 2009-12-08 17:59:32
Message-ID: puk4wx9wjf.fsf@srv.protecting.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In article <13289(dot)1260290974(at)sss(dot)pgh(dot)pa(dot)us>,
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> Julian Mehnle <julian(at)mehnle(dot)net> writes:
>> So far, so good. However, can someone please explain the following to me?
>> wisu-dev=# SELECT regexp_matches('quux(at)foo@bar.zip', '([(at)(dot)]|[^(at)(dot)]+)+', 'g');
>> wisu-dev=# SELECT regexp_matches('quux(at)foo@bar.zip', '([(at)(dot)]|[^(at)(dot)]+){1,2}', 'g');
>> wisu-dev=# SELECT regexp_matches('quux(at)foo@bar.zip', '([(at)(dot)]|[^(at)(dot)]+){1,3}', 'g');

> These might be a bug, but the behavior doesn't seem to me that it'd be
> terribly well defined in any case. The function should be pulling the
> match to the parenthesized subexpression, but here that subexpression
> has got multiple matches --- which one would you expect to get?

Perl seems to return always the last one, but the last one is never just
'p' - so I also think that Julian has spotted a bug.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Fetter 2009-12-08 18:10:30 Re: Tuesday (PST8PDT) Jeff Davis Presents: Operator Exclusion Constraints
Previous Message Julian Mehnle 2009-12-08 17:44:27 Re: regexp_matches() quantified-capturing-parentheses oddity