Skip site navigation (1) Skip section navigation (2)

Re: writing new regexp functions

From: David Fetter <david(at)fetter(dot)org>
To: Jeremy Drake <pgsql(at)jdrake(dot)com>
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 17:12:27
Message-ID: 20070202171227.GA28220@fetter.org (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
On Fri, Feb 02, 2007 at 12:54:30AM -0800, Jeremy Drake wrote:
> 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?

This is great :)

Cheers,
D
-- 
David Fetter <david(at)fetter(dot)org> http://fetter.org/
phone: +1 415 235 3778        AIM: dfetter666
                              Skype: davidfetter

Remember to vote!

In response to

pgsql-hackers by date

Next:From: Kate FDate: 2007-02-02 17:35:36
Subject: Re: Function proposal to find the type of a datum
Previous:From: Pavel StehuleDate: 2007-02-02 17:03:47
Subject: Re: PL/pgSQL RENAME functionality in TODOs

pgsql-patches by date

Next:From: Magnus HaganderDate: 2007-02-02 18:19:24
Subject: Re: pre-vcbuild win32 install docs incorrect
Previous:From: Neil ConwayDate: 2007-02-02 16:25:56
Subject: Re: vcbuild install

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group