Re: Removing Last field from CSV string

2020-05-19 Thread Samuel Roseman
Regular expressions, in my opinion, can be a very powerful text search and replace engine if you know how to use it.Feel free to enhance what I provided below; it seems to work for the example you provided. postgres=# select regexp_replace(substring('Class V,Class VI,Class VII,Competitive Exam,C

Re: Removing Last field from CSV string

2020-05-17 Thread Steve Litt
On Sat, 16 May 2020 23:18:57 +0800 Alex Magnum 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,

Re: Removing Last field from CSV string

2020-05-16 Thread Christian Ramseyer
On 16.05.20 17:18, Alex Magnum wrote: > 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. > Hi Alex Many options to do this with regexp_

Re: Removing Last field from CSV string

2020-05-16 Thread Michael Nolan
On Sat, May 16, 2020 at 10:19 AM Alex Magnum 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

Re: Removing Last field from CSV string

2020-05-16 Thread Adrian Klaver
On 5/16/20 9:31 AM, PALAYRET Jacques wrote: Hello, Perhaps, a statement like :    substring(theString, 1, length(theString)-position(',' IN reverse(theString))) with theString   'Class V,Class VI,Class VII,Competitive Exam,Class VIII*,Class' for example. That's cool. I did a little fiddli

Re: Removing Last field from CSV string

2020-05-16 Thread PALAYRET Jacques
Hello, Perhaps, a statement like : substring(theString, 1, length(theString)-position(',' IN reverse(theString))) with theString 'Class V,Class VI,Class VII,Competitive Exam,Class VIII*,Class' for example. Regards - Météo-France - PALAYRET JACQUES DCSC/MBD jacques.palay...@meteo.

Removing Last field from CSV string

2020-05-16 Thread Alex Magnum
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 remov