Postgres-如何使用like查找包含换行符的文本



我正在查询一个文本字段,并希望使用Postgres提取文本中任何位置包含换行符的行。

例如,我想返回如下文本:

row1 -> hello nthere
row2 -> see you tomorrown

我试着使用如下的东西:

select descr from description_tb where descr like '%n%'

然而,这不起作用,因为可能需要逃跑,但我不知道如何处理我的案件。

它不需要转义,因为它已经被转义了。它需要被解开!

您可以通过在引号前面加一个E来完成此操作。

select descr from description_tb where descr like E'%n%'

或者,你可以只写一行文字,但你可能会受制于你的客户端程序如何传达它:

select descr from description_tb where descr like '%
%'

最新更新