regex - How to remove Unicode characters in Snowflake?
问题描述
I am trying to clean data in snowflake table and I see a lot of unicode characters like \U0028
.
I wrote the following, but not sure how to remove the Unicode.
Select
REGEXP_REPLACE(
REGEXP_REPLACE(
REGEXP_REPLACE(lower('MON \U0028 POP STORE'),
'[/-_.,&#\'"?~;/+|:|/|]'),
'( co|inc|pllc|llc|ltd|plc|corp|pc|corporation|incorporated)$'),
'\\s+',
' ') ;
Is the regex possible or I need to use REPLACE(
data, '\\u0028', '\\u0306')
. Any help would be appreciated.
My data looks like:
VITAMIN \U0026 SUPPLEMENTS STORE
解决方案
根据这些实体在现实生活中的情况,有两种可能的解决方案。
如果这些是 char hex 实体并且\u0026
实际上是在控制台&
中显示的 char,则\u0026
您可能不需要采取任何操作,因为它是可以的。
如果这些是您想从可能使用的文本中删除的文字子字符串
REGEXP_REPLACE( input, '\\s*\\\\U\\d{4}', '' )
细节
\s*
- 0+ 个空格\\
- 反斜杠U
- 一个U
字符\d{4}
- 四位数。
请注意,在字符串文字内部,每个反斜杠必须像\
在字符串中使用的那样进行两次转义,以形成字符串转义序列,如\n
(换行符)、\t
(制表符)等。请参阅转义字符和警告。
推荐阅读
- java - 只调用一次抽象类构造函数,而不是在每个特定类中调用
- ruby-on-rails - AWS S3 在生产中找不到凭证?
- javascript - 如何在 React 应用中使用 HTML 和 JS 来导出组件
- python - 你会如何将这个 Pine Script 嵌套循环翻译成 Python?
- vue.js - 每页行选项显示为 3 个点
- android - 为什么我在 kotlin 中的按钮不起作用?(安卓工作室)
- go - 如果客户端在 10 秒内没有响应,我如何通过超时关闭连接?
- operating-system - CS本科操作系统课程真正教的是什么?
- reactjs - 反应火力基地私人路线
- python - “无效的密码格式或未知的散列算法。” Django - 新用户