pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Eckermann <jeff_eckermann@yahoo.com>
To: Oleg Lebedev <olebedev@waterford.org>
To: Postgres SQL Mailing List <pgsql-sql@postgresql.org>
Subject: Re: substring replacement
Date: Fri, 9 Nov 2001 08:35:42 -0800 (PST)
Message-ID: <20011109163542.41082.qmail@web20805.mail.yahoo.com> (raw)
In-Reply-To: <3BEB0B18.3D6604DA@waterford.org>

I assume you mean that '\n' and '\t' exist as literal
characters in your data, and you simply want to delete
them.
There is no builtin function in PostgreSQL which will
delete a substring ("translate" works for characters,
in the manner of Unix "tr").  You will need to write
one for yourself.  A generic function would be
something like this:
CREATE FUNCTION s(text, text, text)
RETURNS text as '
$_[0] =~ s/$_[1]/$_[2]/;
return $_[0];
' LANGUAGE 'plperl';
Substitute whatever datatype you are using.

--- Oleg Lebedev <olebedev@waterford.org> wrote:
> Hi everybody,
> I am wondering if there is an efficient way to get
> rid of line breaks
> ('\n') and tabs ('\t') from a string. Suppose, I
> have the following
> query:
> SELECT description
> FROM device;
> I don't want the returned description column to
> contain '\n' and '\t'.
> Is it possible to do it efficiently?
> thanks,
> 
> Oleg
> 
> 
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html


__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com



view thread (2+ messages)

Message-ID: <20011109163542.41082.qmail@web20805.mail.yahoo.com>
Permalink:  ../20011109163542.41082.qmail@web20805.mail.yahoo.com/
Also on:    postgresql.org/message-id/20011109163542.41082.qmail@web20805.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jeff_eckermann@yahoo.com, olebedev@waterford.org
  Subject: Re: substring replacement
  In-Reply-To: <20011109163542.41082.qmail@web20805.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox