Re: patch adding new regexp functions

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Jeremy Drake <pgsql(at)jdrake(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>, Neil Conway <neilc(at)samurai(dot)com>, David Fetter <david(at)fetter(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: patch adding new regexp functions
Date: 2007-02-15 13:55:35
Message-ID: 20070215135535.GC4682@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Jeremy Drake wrote:

> The functions added are:
> * regexp_split(str text, pattern text) RETURNS SETOF text
> regexp_split(str text, pattern text, flags text) RETURNS SETOF text
> returns each section of the string delimited by the pattern.
> * regexp_matches(str text, pattern text) RETURNS text[]
> returns all capture groups when matching pattern against string in an
> array
> * regexp_matches(str text, pattern text, flags text) RETURNS SETOF
> (prematch text, fullmatch text, matches text[], postmatch text)
> returns all capture groups when matching pattern against string in an
> array. also returns the entire match in fullmatch. if the 'g' option
> is given, returns all matches in the string. if the 'r' option is
> given, also return the text before and after the match in prematch and
> postmatch respectively.

I think the position the match is in could be important. I'm wondering
if you could define them like

create type re_match(match text, position int)
regexp_split(str text, pattern text) returns setof re_match

or maybe
regexp_split(str text, pattern text, OUT match text, OUT position int);
(not sure of the exact syntax for this one)

so that you would have the position for each match, automatically. Is
this information available in the regex code?

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mario Weilguni 2007-02-15 14:28:23 ERROR: failed to build any 8-way joins
Previous Message Hideyuki Kawashima 2007-02-15 13:08:26 Re: Acclerating INSERT/UPDATE using UPS

Browse pgsql-patches by date

  From Date Subject
Next Message Alvaro Herrera 2007-02-15 15:23:51 Re: Autovacuum launcher
Previous Message Magnus Hagander 2007-02-15 12:30:32 Move cursor support for pl/pgsql