码迷,mamicode.com
首页 > 其他好文 > 详细

Hive 处理敏感字段 字符串替换

时间:2020-01-15 13:36:37      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:select   concat   正则表达   正则   sele   匹配   特殊字符   scene   add   

使用regexp_replace格式:

regexp_replace(address,"正则表达式","替代字符")


(1)匹配所有字符:

select regexp_replace(address, ‘.*‘, ‘***‘) from table;


(2)匹配指定字符:

select regexp_replace(‘2016-06-05‘, ‘-‘, ‘‘) from table;


(3)匹配特殊字符(换行符):

select regexp_replace(name,‘\\\\n‘,‘‘) from table;

 

例子:

SELECT  concat(SUBSTR(user_log_acct, 1, 6), ‘*****‘) AS user_log_acct  -- 只保留前六位,后面脱敏

SELECT  regexp_replace(scene, ‘@@‘, ‘_‘) AS scene  -- 替换指定的字符串

  


原文链接:https://blog.csdn.net/lhxsir/article/details/90374941

Hive 处理敏感字段 字符串替换

标签:select   concat   正则表达   正则   sele   匹配   特殊字符   scene   add   

原文地址:https://www.cnblogs.com/Allen-rg/p/12196156.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!