hive中 regexp_replace的用法,替换特殊字符问题

数据仓库中有的字段不合格,有特殊字符,比如换行符。

poi_name
\n19013
\n12013

怎么把换行符替换掉呢?

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-StringOperators

regexp_replace(string INITIAL_STRING, string PATTERN, string REPLACEMENT)

Returns the string resulting from replacing all substrings in INITIAL_STRING that match the java regular expression syntax defined in PATTERN with instances of REPLACEMENT. For example, regexp_replace("foobar", "oo|ar", "") returns 'fb.' Note that some care is necessary in using predefined character classes: using '\s' as the second argument will match the letter s; '\s' is necessary to match whitespace, etc.

官网说用两个反斜杠代替一个,即一个反斜杠用来转义。

实践了一下,不行,得4个

select regexp_replace(poi_name,'\\\\n','') 

poi_name
19013
12013
posted @   Ryan.Miao  阅读(106774)  评论(1编辑  收藏  举报
编辑推荐:
· 理解Rust引用及其生命周期标识(下)
· 从二进制到误差:逐行拆解C语言浮点运算中的4008175468544之谜
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
阅读排行:
· 2025成都.NET开发者Connect圆满结束
· 后端思维之高并发处理方案
· 千万级大表的优化技巧
· 在 VS Code 中,一键安装 MCP Server!
· 10年+ .NET Coder 心语 ── 继承的思维:从思维模式到架构设计的深度解析
历史上的今天:
2015-11-07 省市县三级联动
点击右上角即可分享
微信分享提示