Re: Removing Last field from CSV string

Поиск
Список
Период
Сортировка
Искать
От
Michael Nolan
Тема
Re: Removing Last field from CSV string
Дата
в 17:29:34
Msg-id
CAOzAqu+7uFb96+b7SJ_Hf_NfhR7u-q2i_bXNwVgwH3c288adWg@mail.gmail.com
Ответ на
Список
Дерево обсуждения
Removing Last field from CSV string Alex Magnum <magnum11200@gmail.com>
Re: Removing Last field from CSV string Steve Litt <slitt@troubleshooters.com>
Re: Removing Last field from CSV string Samuel Roseman <muelrose@yahoo.com>
Re: Removing Last field from CSV string Christian Ramseyer <rc@networkz.ch>
Re: Removing Last field from CSV string Michael Nolan <htfoot@gmail.com>


On Sat, May 16, 2020 at 10:19 AM Alex Magnum <magnum11200@gmail.com> wrote:
Hi,

I have a string that I want to cut to 60 char and then remove the last field and comma.

substring('Class V,Class VI,Class VII,Competitive Exam,Class VIII,Class X,Class XI,Class IX,Class XII',1,60);

substring | Class V,Class VI,Class VII,Competitive Exam,Class VIII,Class

Now I try to remove the last  field and comma  ",Class"

To get  Class V,Class VI,Class VII,Competitive Exam,Class VIII

Is there a function or easy way to do this?
Any help would be appreciated.

You should be able to write a posix patter that does this, you want to keep everything except a comma followed by 0 or more non-commas and the end of the string boundary to make sure it gets just the last such match.
--
Mike Nolan
В списке pgsql-general по дате отправления
От: Don Seiler
Дата:
От: Tom Lane
Дата:
FAQ