Hive:删除特殊字符并保留单词之间的 space

Hive: remove the special characters and keep the space between the word

我有自定义 table 并且此列中有特殊字符。我想删除特殊字符并保留单词之间的 space。

我试试这个查询。

select customer_ID, REGEXP_REPLACE(姓名, '[^0-9A-Za-z]', '') 来自客户

但是这个查询删除了所有特殊字符和space。

如何特殊字符并在该列中的单词之间保留 space?

如果您想保留空格,则可以将其添加到否定字符 class。

要匹配字符 class 一次或多次,您可以在字符 class 后添加 + 号。

[^0-9A-Za-z ]+

您的查询如下:

select customer_ID, REGEXP_REPLACE(name, '[^0-9A-Za-z ]+', '') from customer