Is there an easy way in PostgreSQL to escape newlines, carriage returns, and tabs?
4
votes
2
answers
24976
views
Let's say I want to escape these to see a similar string
SELECT *
FROM ( VALUES
(E'\r\n\t FOO BAR \t\n\r')
) AS t(str);
How do I get the c-style escapes,
\r\n\t FOO BAR \t\n\r
back out?
SELECT *
FROM ( VALUES
(E'foo\nfoo',E'\n\tBAR\t','baz'),
(E'quz','qaz','quz')
) AS t(x,y,z);
x | y | z
-----+------------------+-----
foo+| +| baz
foo | BAR |
quz | qaz | quz
(2 rows)
Want instead..
x | y | z
----------+------------------+-----
foo\nfoo | \n\tBAR | baz
quz | qaz | quz
(2 rows)
Asked by Evan Carroll
(65502 rep)
May 25, 2017, 03:44 AM
Last activity: Apr 4, 2021, 03:36 AM
Last activity: Apr 4, 2021, 03:36 AM