sql - Split string by space and character as delimiter in Oracle with regexp_substr -


i'm trying split string regexp_subtr, can't make work.

so, first, have query

select regexp_substr('helloworld - test!' ,'[[:space:]]-[[:space:]]') dual 

which nicely extracts delimiter - blank-blank

but then, when try split string option, doesn't work.

select regexp_substr('helloworld - test!' ,'[^[[:space:]]-[[:space:]]]+')from dual 

the query returns nothing.

help appreciated! thanks

sql fiddle

oracle 11g r2 schema setup:

create table test( str )           select 'hello world - test-test! - test' dual union select 'hello world2 - test2 - test-test2' dual; 

query 1:

select str,        column_value occurrence,        regexp_substr( str ,'(.*?)([[:space:]]-[[:space:]]|$)', 1, column_value, null, 1 ) split_value   test,        table(          cast(            multiset(              select level                dual              connect level < regexp_count( str ,'(.*?)([[:space:]]-[[:space:]]|$)' )            )            sys.odcinumberlist          )        ) 

results:

|                               str | occurrence |  split_value | |-----------------------------------|------------|--------------| |   hello world - test-test! - test |          1 |  hello world | |   hello world - test-test! - test |          2 |   test-test! | |   hello world - test-test! - test |          3 |         test | | hello world2 - test2 - test-test2 |          1 | hello world2 | | hello world2 - test2 - test-test2 |          2 |        test2 | | hello world2 - test2 - test-test2 |          3 |   test-test2 | 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -