According to your sample data and desired output, in fact you want to extract values between -
in a string like Anaheim-Santa Ana-Irvine
and then join them with a value like CA
so the result as you mentioned should be:
Anaheim CA
Santa Ana CA
Irvine CA
Using regx_substr
for such these scenarios is very useful, you can achive the result by cross joining the extracted values with a generated list(table) of ids with count of number of values in the complex string:
SQL> create table strTable(complexStr varchar(100),strId varchar(5));
Table created.
SQL> insert into strTable values('Anaheim-Santa Ana-Irvine','CA');
1 row created.
SQL> commit;
Commit complete.
SQL> select trim(regexp_substr(t.complexStr, '[^-]+', 1, ids.column_value)) city,
2 t.strId state
3 from strTable t
4 cross join
5 table (cast (multiset
6 (select level from dual connect by level <= regexp_count(t.complexStr, '-')+1)
7 AS sys.odciNumberList)) ids;
CITY STATE
--------------------
Anaheim CA
Santa Ana CA
Irvine CA
SQL> drop table strTable;
Table dropped.
SQL>