array_agg to array

Поиск
Список
Период
Сортировка
Искать
От
Philipp Kraus
Тема
array_agg to array
Дата
в 09:14:45
Msg-id
CDD491B7-CD8D-4CA4-9F20-F62A73E1EBE7@tu-clausthal.de
Список
Дерево обсуждения
array_agg to array Philipp Kraus <philipp.kraus@tu-clausthal.de>
Re: array_agg to array Pavel Stehule <pavel.stehule@gmail.com>
Re: array_agg to array Torsten Förtsch <tfoertsch123@gmail.com>
Re: array_agg to array Philipp Kraus <philipp.kraus@tu-clausthal.de>
Hello,

I have got a function with a reg expr to split chemical formulas e.g. H2O -> H2 O.

CREATE OR REPLACE FUNCTION daimon.text2sumformula(text) RETURNS text[] AS $$
    select array_agg(i::text) as e from ( select unnest( regexp_matches( $1, '[0-9]*[A-Z][a-z]?\d*|\((?:[^()]*(?:\(.*\))?[^()]*)+\)\d+', 'g') ) ) i;
$$ LANGUAGE SQL IMMUTABLE;

For H2O I get an array with {(H2),(O)}
How I can return the inner elements as text, I would like to get {H2,O} without round brackets?

Thanks

Phil



В списке pgsql-general по дате отправления
От: tango ward
Дата:
От: Pavel Stehule
Дата:
Сообщение: Re: array_agg to array
FAQ