select regexp_matches('a a a', '([a-z]) a','g');

From: "Marc Mamin" <M(dot)Mamin(at)intershop(dot)de>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: select regexp_matches('a a a', '([a-z]) a','g');
Date: 2009-05-07 14:51:31
Message-ID: C4DAC901169B624F933534A26ED7DF31010A50FF@JENMAIL01.ad.intershop.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello,

I wonder if someone has an idea for this problem:

I have a string that contains a serie of chars, separated by single
spaces.

e.g 'a b x n r a b c b'

Having such a string, I d'like to get a list of all predecessors of a
given character.
In the example, the predecessors of b are a,a,c.

If I now have the string 'a a a', the predecessors of 'a' are a,a

I tried to use regexp_matches for this:

select regexp_matches('a a a', '([a-z]) a','g');
=> {"a "} only

As the second parameter of the function matches the first 2 'a',
only the trailing ' a' will be used to seek for further matching...

Cheers,

Marc Mamin

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Scott Marlowe 2009-05-07 18:54:09 Re: Distinct oddity
Previous Message Ian Barwick 2009-05-07 08:47:03 Re: ask about epoch query with datetime