Reputation: 67
In my Hive table, i have an email address column : [email protected] i want to display "gmail" alone. I tried using regexp_extract but not getting the desired output. nowhere near.
Also for email ids like [email protected] , i want the output to be "ffff.nec.co"
Below is my expression : select regexp_extract('[email protected]','.([^.]+)') but it does not bring the desired output. Please help me out guys. Regexp or substr is fine for me.
Upvotes: 2
Views: 2517
Reputation: 44921
Option 1
hive> select regexp_extract('[email protected]' ,'@(.*)\\.',1);
OK
gmail
hive> select regexp_extract('[email protected]' ,'@(.*)\\.',1);
OK
ffff.nec.co
Option 2
hive> select regexp_extract('[email protected]' ,'(?<=@).*(?=\\.)',0);
OK
gmail
hive> select regexp_extract('[email protected]' ,'(?<=@).*(?=\\.)',0);
OK
ffff.nec.co
Upvotes: 1