如何在 Presto 中查找特殊字符,如 \t \n \u 和单引号 (“)

how to find special character like \t \n \u and single quotation mark (") in presto

提问人:justnewbie89 提问时间:11/26/2019 最后编辑:BMDanjustnewbie89 更新时间:4/23/2021 访问量:2323

问:

我正在使用 presto。我有一个包含地址信息的表。它具有 varchar 格式。

如何查找包含特殊字符的地址,例如:

  • \t(选项卡)
  • \n(换行符)
  • \u
  • 单引号 (')
普雷斯托

评论


答:

2赞 Piotr Findeisen 11/26/2019 #1

您可以与包含换行符的文本一起使用。为此使用 unicode 转义的便捷方法(换行符在 Unicode 中):LIKE\nU+000A

col LIKE U&'%\000A%'

U&'...'创建字符串文字,就像 . 唯一的区别是支持 Unicode 的转义。'...'U&'...'\hhhh

例:

presto:default> SELECT 'abc
             -> def' LIKE U&'%\000A%';
 _col0
-------
 true
(1 row)

在 Presto 324 上测试。

评论

0赞 Piotr Findeisen 11/29/2019
别客气。我创建了 github.com/prestosql/presto/issues/2113 以便我们记录这一点。另外,如果您有任何不适合 SO 的问题,我邀请您加入 Presto 社区 Slack prestosql.io/slack.html