Re: Regular expression that splits CSV string into table

Поиск
Список
Период
Сортировка
От Nick
Тема Re: Regular expression that splits CSV string into table
Дата
Msg-id 1d17906f-3f85-4143-9b91-e4be8c9df1c9@m17g2000prl.googlegroups.com
обсуждение исходный текст
Ответ на Regular expression that splits CSV string into table  (Nick <nboutelier@gmail.com>)
Ответы Re: Regular expression that splits CSV string into table  (Alvaro Herrera <alvherre@commandprompt.com>)
Список pgsql-general
Yes, that gets down to the root of my question... what is the
expression that would properly split the values? -Nick

On Sep 10, 4:43 pm, brick...@gmail.com (bricklen) wrote:
> On Fri, Sep 10, 2010 at 3:43 PM, Nick <nboutel...@gmail.com> wrote:
> > What would be the regexp_split_to_table pattern that splits a comma
> > separated string into a table? Im having trouble when a string
> > contains commas or there are commas at the beginning or end
>
> > String
> > ',one,two,''three,four'',five,six,'
>
> > Should return
> > ,one
> > two
> > three,four
> > five
> > six,
>
> You can roll your own function, or try regexp_split_to_table, though
> you will probably have to use a different delimiter if you don't want
> it to break on "three,four".
> Eg.
>
> select regexp_split_to_table('"one","two","three,four","five"',',');
>  regexp_split_to_table
> -----------------------
>  "one"
>  "two"
>  "three
>  four"
>  "five"
>
> --
> Sent via pgsql-general mailing list (pgsql-gene...@postgresql.org)
> To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-general


В списке pgsql-general по дате отправления:

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: sql DO in rule 9.0rc1
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Regular expression that splits CSV string into table