前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >hive中 regexp_replace的用法,替换特殊字符问题

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

作者头像
Ryan-Miao
发布2018-12-07 10:58:41
9.2K0
发布2018-12-07 10:58:41
举报
文章被收录于专栏:Ryan MiaoRyan Miao

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

代码语言:javascript
复制
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 ```

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-11-07 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档