Search code examples
oracle-databaseregexp-replace

Split the camel cased sentence into words


I need to split the camel cased sentence into words using SQL.

Example: 'IHaveAPen' into 'I Have A Pen'

I'm using the regex

select regexp_replace('IAmGoodBoy','([^^])(A-Z)','\1 \2 \3') from dual;

to split strings by capital letter.

but it doesn't work.

Can this be done?


Solution

  • Try with the following query:

    select regexp_replace('IAmGoodBoy','([A-Z][^A-Z]*)','\1 ') from dual;