如何从 Hive 中的字符串字段中删除某些字符?
How to get rid of some characters from a field of string in Hive?
我想删除字段中的一些 stting 格式的字符。例如,将标点符号替换为空白字符。如何实现给定候选字符擦除。
将regexp_replace
与模式一起使用,例如'[_.,!?-]'
,列出您要在模式中删除的字符。这将用空格替换模式中的字符:
select regexp_replace('test_string_with-puctuations,.!?','[_.,!?-]',' ');
输出:
test string with puctuations
我想删除字段中的一些 stting 格式的字符。例如,将标点符号替换为空白字符。如何实现给定候选字符擦除。
将regexp_replace
与模式一起使用,例如'[_.,!?-]'
,列出您要在模式中删除的字符。这将用空格替换模式中的字符:
select regexp_replace('test_string_with-puctuations,.!?','[_.,!?-]',' ');
输出:
test string with puctuations