Hive Regular Expression

2019-09-10 15:32发布

Can any one let me know how to use the regular expression in Hive latest versions in one scenario.I have one column with different values-many rows and i want to extract data after after val data as below

col1 -> Money;valone:this is savings account

col2 -> Money;valtwo:Not a general account

col3 -> Money;valthree:your credit card

col4 -> Money;valFour:incorrect acctnumber

when i do select query using regular expression

select colname,regexp_extract(colname,*.;val?:[^...,1) from hive_table;

I want the output as Output: this is savings account
Not a general account
your credit card
incorrect acctnumber


I also tried valone|valtwo|valthree|valfour....
but there are almost thousands of records which i cannot write valone|valtwo|valthree|valfour ................................. for each record.

Can any one help on this?

1条回答
别忘想泡老子
2楼-- · 2019-09-10 16:07

I think there is problem with your regexp.Please try following query.

select colname,regexp_extract(colname,'.*;.*:(.*)',1) from table_name;
查看更多
登录 后发表回答