This should work:
Code:SQL> select * from hosts; HOSTID ---------------------------------------------------------------------- host1:12.134.23.45,host2:34.56.76.102,hosts3,hosts4:10.2.1.0,12.3.4.3, hosts5.local:198.162.10.1,hosts6.local.com SQL> with t as ( 2 select regexp_substr(hostid, '[^,]+', 1, level) str 3 from hosts 4 connect by level <= length(hostid)-length(replace(hostid,','))+1) 5 select regexp_substr(str, '.*[a-z]+[^:]*',1,1,'i') hostname 6 , ltrim(regexp_substr(str, '(^|:)[^:a-z]+$',1,1,'i'),':') ip 7 from t; HOSTNAME IP -------------------- -------------------- host1 12.134.23.45 host2 34.56.76.102 hosts3 hosts4 10.2.1.0 12.3.4.3 hosts5.local 198.162.10.1 hosts6.local.com 7 rows selected.




Reply With Quote