pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedsubstring replacement
2+ messages / 2 participants
[nested] [flat]
* substring replacement
@ 2001-11-08 22:45 Oleg Lebedev <olebedev@waterford.org>
2001-11-09 16:35 ` Re: substring replacement Jeff Eckermann <jeff_eckermann@yahoo.com>
0 siblings, 1 reply; 2+ messages in thread
From: Oleg Lebedev @ 2001-11-08 22:45 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: substring replacement
2001-11-08 22:45 substring replacement Oleg Lebedev <olebedev@waterford.org>
@ 2001-11-09 16:35 ` Jeff Eckermann <jeff_eckermann@yahoo.com>
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Eckermann @ 2001-11-09 16:35 UTC (permalink / raw)
To: Oleg Lebedev <olebedev@waterford.org>; pgsql-sql
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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-11-09 16:35 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-11-08 22:45 substring replacement Oleg Lebedev <olebedev@waterford.org>
2001-11-09 16:35 ` Jeff Eckermann <jeff_eckermann@yahoo.com>
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