Re: writing new regexp functions

From: Jeremy Drake <pgsql(at)jdrake(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: writing new regexp functions
Date: 2007-02-02 08:54:30
Message-ID: Pine.BSO.4.64.0702020048510.28908@resin.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On Fri, 2 Feb 2007, Jeremy Drake wrote:

> jeremyd=# select * from regexp_matches('foobarbequebaz',
> $re$(bar)(beque)$re$, false);
> prematch | fullmatch | matches | postmatch
> ----------+-----------+-------------+-----------
> \N | \N | {bar,beque} | \N
> (1 row)

I just changed this to fill in fullmatch when the bool is false, so this
one would look like:
prematch | fullmatch | matches | postmatch
----------+-----------+-------------+-----------
\N | barbeque | {bar,beque} | \N
(1 row)

I also removed my check for capture groups, since in this setup you could
get useful output without any. I am still trying to decide whether or not
to add back an error if you called the no-bool version which just returns
the array, and you do not have any capture groups. ISTM this is likely an
oversight on the query author's part, and it would be helpful to alert him
to this.

If you have no capture groups, the matches array is empty (not null). If
the match happened at the start of the string, the prematch is an empty
string, and if the match happened at the end of the string, the postmatch
is an empty string.

> Reasonable?

--
It's odd, and a little unsettling, to reflect upon the fact that
English is the only major language in which "I" is capitalized; in many
other languages "You" is capitalized and the "i" is lower case.
-- Sydney J. Harris

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Meskes 2007-02-02 09:01:26 Re: Why is ecpg segfaulting on buildfarm member "clownfish"?
Previous Message NikhilS 2007-02-02 08:54:01 Re: --enable-debug does not work with gcc

Browse pgsql-patches by date

  From Date Subject
Next Message Magnus Hagander 2007-02-02 09:12:04 pre-vcbuild win32 install docs incorrect
Previous Message Jeremy Drake 2007-02-02 08:15:15 Re: writing new regexp functions