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.