Re: select all matches for a regular expression ?

From: "Anton Melser" <melser(dot)anton(at)gmail(dot)com>
To: "Peter Childs" <peterachilds(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: select all matches for a regular expression ?
Date: 2007-02-23 14:33:37
Message-ID: 92d3a4950702230633k358f4309l4fc348ae2513138c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 23/02/07, Peter Childs <peterachilds(at)gmail(dot)com> wrote:
> On 23/02/07, Anton Melser <melser(dot)anton(at)gmail(dot)com> wrote:
> > Hi,
> > I need to be able to get all the matches for a particular regexp from
> > a text field that I need to use in another query in a function. Is
> > this possible with plpgsql? Do I have to install the perl language?
> > Cheers
> > Anton
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 2: Don't 'kill -9' the postmaster
> >
>
> yes. use "like" or "~"
>
> see
> http://www.postgresql.org/docs/8.2/static/functions-matching.html
>
> There is no need to use perl.

... I have read and re-read that page many times - I must be stupid
:-(. For me both like and ~ on an expression will return true or
false, and not a set of values. I have managed to get *one* value with
substring(), but I need to get them all...
As an example, I need to find all the occurences of digits in the following text

myvar := 'hello4 is 4 very n1ce num8er';

so select substrings(myvar, '([0-9]));

will return
4
4
1
8

Is *this* possible without perl? Could you give a paragraph number on
that page if the info is there so I know exactly where to look?
Thanks again,
Anton

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jasbinder Singh Bali 2007-02-23 14:34:51 Re: server closed unexpectedly while executing a function
Previous Message Bill Moran 2007-02-23 14:32:54 Re: Wikipedia on Postgres (was Re: postgresql vs mysql)