Received: from web20805.mail.yahoo.com (web20805.mail.yahoo.com [216.136.226.194]) by postgresql.org (8.11.3/8.11.4) with SMTP id fA9JMLm04466 for ; Fri, 9 Nov 2001 14:22:21 -0500 (EST) (envelope-from jeff_eckermann@yahoo.com) Message-ID: <20011109163542.41082.qmail@web20805.mail.yahoo.com> Received: from [65.11.165.34] by web20805.mail.yahoo.com via HTTP; Fri, 09 Nov 2001 08:35:42 PST Date: Fri, 9 Nov 2001 08:35:42 -0800 (PST) From: Jeff Eckermann Subject: Re: substring replacement To: Oleg Lebedev , Postgres SQL Mailing List In-Reply-To: <3BEB0B18.3D6604DA@waterford.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200111/149 X-Sequence-Number: 5533 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 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