0
votes

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

1 Answers

0
votes

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

select colname,regexp_extract(colname,'.*;.*:(.*)',1) from table_name;