Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 替换(屏蔽)配置单元中的特定值_Regex_Hive - Fatal编程技术网

Regex 替换(屏蔽)配置单元中的特定值

Regex 替换(屏蔽)配置单元中的特定值,regex,hive,Regex,Hive,大家好,我在替换/屏蔽包含account的列数据时遇到了一个问题(没有标准长度,可能是10位或更多),假设我有如下数据: 6285669871 already in history 6281246983002 not in history 08693461287 not found 6194637899 already in history 我想要的是将它们屏蔽到“..(附加日志信息)”中 我尝试使用: regexp_replace(Column1,'[0-9]{7}','<

大家好,我在替换/屏蔽包含account的列数据时遇到了一个问题(没有标准长度,可能是10位或更多),假设我有如下数据:

6285669871 already in history  
6281246983002 not in history  
08693461287 not found  
6194637899 already in history 
我想要的是将它们屏蔽到“..(附加日志信息)”中

我尝试使用:

regexp_replace(Column1,'[0-9]{7}','<account>')
regexp_replace(第1列,'[0-9]{7}','')
但它不起作用,因为账号长度并不总是7位数,有没有更好的方法

谢谢

我建议

regexp_replace(Column1,'^[0-9]{7,}','<account>')

regexp\u replace(第1列,^[0-9]{7,}',。

尝试
'[0-9]{7,}'
匹配7个或更多数字。在前面加上
^
'^[0-9]{7,}'
)如果它们仅出现在字符串开头。@WiktorStribiżew会这样做,我稍后会更新,谢谢您的回答。我认为您的解决方案非常有效,但是我们并不真正需要“^”,因为有些数据并非总是以账号开头,例如“账号=6113577”不可用