From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | David Fetter <david(at)fetter(dot)org>, Jeremy Drake <pgsql(at)jdrake(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>, Neil Conway <neilc(at)samurai(dot)com> |
Subject: | Re: patch adding new regexp functions |
Date: | 2007-02-17 16:19:11 |
Message-ID: | 19417.1171729151@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> David Fetter wrote:
>> What is it about having the whole match, pre-match and post-match
>> available that you're objecting to? Are you saying there aren't
>> common uses for any or all of these? Regular expression users use
>> them all over the place,
> You keep saying that, and I keep saying please show a use case.
Maybe I'm missing something, but ISTM that given the ability to return
multiple match substrings there is no need for such features. Given
an arbitrary regex 'xyz', write '^(.*)(xyz)(.*)$' and you'll get back
the pre-match, whole match, and post-match in addition to any
parenthesized substrings that 'xyz' contains. If you only need some
of them, you can leave out the corresponding parts of this pattern.
So I'd vote against complicating the API in order to make special
provision for these results. I claim that all we need is a function
taking (string text, pattern text, flags text) and returning either
array of text or setof text containing the matched substrings in
whatever order is standard (order by left-parenthesis position,
I think). In the degenerate case where there are no parenthesized
subpatterns, just return the whole match as a single element.
As for the argument about array vs setof, I could see doing both to
end the argument of which one is really superior for any particular
problem.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-02-17 16:26:53 | Re: RFC: Temporal Extensions for PostgreSQL |
Previous Message | Joshua D. Drake | 2007-02-17 15:50:50 | Re: New feature request: FlashBack Query |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-02-17 16:42:20 | Re: \prompt for psql |
Previous Message | Bruce Momjian | 2007-02-17 15:07:09 | Re: \prompt for psql |