0
How to remove or include "line break", "enter", "new line" from a string result in postgres.
The result is:
comentário
Texto do comentário
Mais texto
And I want to:
comentário
Texto do comentário - Mais texto
Or the other way around
0
How to remove or include "line break", "enter", "new line" from a string result in postgres.
The result is:
comentário
Texto do comentário
Mais texto
And I want to:
comentário
Texto do comentário - Mais texto
Or the other way around
1
To remove, we can use:
select regexp_replace(sua_coluna, E'[\\n\\r]+', ' - ', 'g' )
OR
select regexp_replace(sua_coluna, '[\n\r]+', ' - ', 'g' )
To includes a new use line:
select E'Primeira Linha\nSegunda linha.'
OR
select E'Primeira Linha'||chr(10)||'Segunda linha.'
Or as @David
select E'Primeira Linha'||chr(13)||'Segunda linha.'
For more information, read the manual http://www.postgresql.org/docs/current/static/functions-matching.html
Browser other questions tagged sql postgresql line-breaks
You are not signed in. Login or sign up in order to post.
In addition to Chr(10) = Carriage Return = Carriage Return, we have Chr(13) = Line Feed = Line Feed. :)
– David
Thank you @David, I edited the reply
– Tiago Oliveira de Freitas