select regexp_matches('a a a', '([a-z]) a','g'); - Mailing list pgsql-sql

From Marc Mamin
Subject select regexp_matches('a a a', '([a-z]) a','g');
Date
Msg-id C4DAC901169B624F933534A26ED7DF31010A50FF@JENMAIL01.ad.intershop.net
Whole thread Raw
In response to Distinct oddity  (Maximilian Tyrtania <maximilian.tyrtania@onlinehome.de>)
List 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


pgsql-sql by date:

Previous
From: Ian Barwick
Date:
Subject: Re: ask about epoch query with datetime
Next
From: Scott Marlowe
Date:
Subject: Re: Distinct oddity