On Sat, 17 Feb 2007, Tom Lane wrote: > Jeremy Drake <[EMAIL PROTECTED]> 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" ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster