嗨大师们我在替换/屏蔽包含帐户的列数据时遇到了一个问题(没有标准长度,它可能是 10 位或更多),假设我有这样的数据:
6285669871 already in history
6281246983002 not in history
08693461287 not found
6194637899 already in history
我想要的是将它们屏蔽为“..(附加日志信息)”
我尝试使用:
regexp_replace(Column1,'[0-9]{7}','<account>')
但它不起作用,因为帐号长度并不总是 7 位数字,有没有更好的方法?
谢谢
最佳答案
我建议
regexp_replace(Column1,'^[0-9]{7,}','<account>')
详情
^
- 字符串的开始[0-9]{7,}
- 7 或更多位
参见 regex demo .
关于regex - 替换(屏蔽)HIVE 中的特定值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49692575/