Hive 處理敏感字段 字符串替換


使用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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM