Re: Removing spaces - Mailing list pgsql-general

From Richard Huxton
Subject Re: Removing spaces
Date
Msg-id 200302191919.51767.dev@archonet.com
Whole thread Raw
In response to Removing spaces  (Dave Smith <dave.smith@candata.com>)
Responses Re: Removing spaces
List pgsql-general
On Wednesday 19 Feb 2003 5:07 pm, Dave Smith wrote:
> I have a field of type text that has a value like
>
> 'hello   \nworld   \n'
>
> I would like to remove the trailing blanks between the last character
> and the newline. I would like to use replace with a regx  like
> /[ ]+\n/\n/ but it does not seem to work.

The replace function doesn't handle regexps AFAIK - you could look at
SUBSTRING() in the POSIX Regexp section of the functions reference but I
don't think that's going to do it either.

The problem is you seem to want to remove spaces after "hello" and "world" - I
think that means you need perl regexps or a loop.

Unless some posix guru steps forward, I'd say the easiest way is to build a
loop that repeatedly calls replace(my_string,' \n','\n')
--
  Richard Huxton

pgsql-general by date:

Previous
From: "Daniel Schuchardt"
Date:
Subject: Re: BLOB or BYTEA field
Next
From: "Nigel J. Andrews"
Date:
Subject: Re: How do I upgrade or coexist PostgreSQL on a Cobalt