hive中的regexp_extract给出错误

时间:2016-01-17 09:11:00

标签: regex hive

我在表格中有一些数据,例如:

id,params  
123,utm_content=doit|utm_source=direct|   
234,utm_content=polo|utm_source=AndroidNew|

使用regexp_extract的所需数据:

id,channel,content
123,direct,doit
234,AndroidNew,polo

使用的查询:

Select id, REGEXP_extract(lower(params),'(.*utm_source=)([^\|]*)(\|*)',2) as channel, REGEXP_extract(lower(params),'(.*utm_content=)([^\|]*)(\|*)',2)  as content from table;

显示错误'*悬空元字符'并返回错误代码2

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

请注意,在 hive中,您需要加倍反斜杠。

你的正则表达式应该是

(.*utm_content=)([^|]*)(\\|*)