Re: patch adding new regexp functions - Mailing list pgsql-patches

From Jeremy Drake
Subject Re: patch adding new regexp functions
Date
Msg-id Pine.BSO.4.64.0702171602390.18849@resin.csoft.net
Whole thread Raw
In response to Re: patch adding new regexp functions  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
On Sat, 17 Feb 2007, Tom Lane wrote:

> Jeremy Drake <pgsql@jdrake.com> writes:
> > On Sat, 17 Feb 2007, Tom Lane wrote:
> >> 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
>
> > For this function, it would be setof array of text, as the capture groups
> > would definitely go in an array, but if you asked for global in the flags,
> > there could be more than one match in the string.
>
> Oh, right.  And you could do a 2-D array if you wanted it all in one
> blob (or a guarantee of order).

I don't think that there is much of an argument for having this one return
a 2d array, in this particular case, even perl requires you to build a
loop, IIRC.

my $str = 'foobarbecuebazilbarf';
while($str=~/(b[^b]+)(b[^b]+)/g) {
    print $1, "\t", length($1), "\n";
    print $2, "\t", length($2), "\n";
    print "---\n";
}

bar     3
becue   5
---
bazil   5
barf    4
---

> So no need for record-returning functions?
No.


--
Go placidly amid the noise and waste, and remember what value there may
be in owning a piece thereof.
        -- National Lampoon, "Deteriorata"

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: patch adding new regexp functions
Next
From: Bruce Momjian
Date:
Subject: Re: patch for contrib/xml2