i want to get a numeric value immediately after a particular word in string In hive for example : APDSGDSCRAM051 in that i need to get numeric value after word RAM is it possible in hive
Note: its not a fixed length string
i want to get a numeric value immediately after a particular word in string In hive for example : APDSGDSCRAM051 in that i need to get numeric value after word RAM is it possible in hive
Note: its not a fixed length string
Here you go, you need to use substr and instr pre-defined hive functions:
create table str_testing (c string);
insert into table str_testing values ('APDSGDSCRAM051');
select substr(c, instr(c, 'RAM') + 3) from str_testing;
OK
051
Time taken: 0.243 seconds, Fetched: 1 row(s)
As explained here, you can implemented in hive as
select regexp_extract(name, '\\d+', 0) from <table_name>;
Note: I do not have environment for Hive configured so you can check this by running at your end. Ya this will work only for first set of numbers found in your string, if you string has numbers at multiple places this might fail.