I have data in a line like this.
age:32, name:Michael John, country:USA, age:34, name:Lewis Carl, country:USA, age:53, name:Larry Moore, country:Mexico
And I would like to capture all the names from above line.
expected output:-
Michael John, Lewis Carl, Larry Moore
How can I achieve that?
Please take note I show 3 datasets but the dataset is dynamic and can be more than 3. So the expected name list can be more than 3.
I have tried this way
select regexp_replace(s1,'(name:\w+( +\w+)*)','<\1>') from ( select 'age:32, name:Michael John, country:USA, age:34, name:Lewis Carl, country:USA, age:53, name:Larry Moore, country:Mexico' s1 from dual ) ;
here is the output
age:32, <name:Michael John>, country:USA, age:34, <name:Lewis Carl>, country:USA, age:53, <name:Larry Moore>, country:Mexico
But I have no idea how to remove the "age" and "country" that I would like to omit.
Please advise.