On Thu, Feb 01, 2007 at 10:16:54PM -0800, Jeremy Drake wrote:
> On Thu, 1 Feb 2007, David Fetter wrote:
> > On Thu, Feb 01, 2007 at 05:11:30PM -0800, Jeremy Drake wrote:
> > > Anyway, the particular thing I was writing was a function like
> > > substring(str FROM pattern) which instead of returning just the
> > > first match group, would return an array of text containing all
> > > of the match groups.
> If you are subscribed to -patches, I sent my code to date there
> earlier this evening. I also said that I wanted to make a function
> that split on a pattern (like perl split) and returned setof text.
> > That'd be great! People who use dynamic languages like Perl would
> > feel much more at home having access to all the matches. While
> > you're at it, could you could make pre-match and post-match
> > (optionally--I know it's expensive) available?
> I could, but I'm not sure how someone would go about accessing such
> a thing. What I just wrote would be most like this perl: @foo =
> Where would pre and post match fit into this? Are you talking about a
> different function?
Yes, although it might have the same name, as in regex_match(pattern
TEXT, string TEXT, return_pre_and_post BOOL).
> Or sticking prematch at the beginning of the array and postmatch at
> the end? I could also put the whole match somewhere also, but I did
> not in this version.
The data structure could be something like
TYPE matches (
> The code I wrote returns a text which is one-dimensional, has a lower
> bound of 1 (as most postgres arrays do), where if there are n capture
> groups, ra has the first capture group and ra[n] has the last one.
> Since postgres has an option to make different lower bounds, I suppose I
> could have an option to put the prematch in [-1], the entire match in ,
> and the postmatch in [n+1]. This seems to be odd to me though.
Odd == bad. I think the pre- and post-matches should be different in
essence, not just in index :)
> I guess I'm saying, I agree that the entire match, prematch, and postmatch
> would be helpful, but how would you propose to present these to the user?
See above :)
David Fetter <[EMAIL PROTECTED]> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Remember to vote!
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings