Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

regular expression retrieve string before and after a string

user598242Nov 14 2018 — edited Nov 14 2018

I want to retrieve string before 'is' or 'I/S', and string after 'is' or 'I/S'

with TableA as

(

select 'Pen is red' as A FROM DUAL

UNION

select 'PENCIL I/S GREEN' as A FROM DUAL

)

select

   ??  as stringBefore,

    ?? as stringAfter   

from TableA

the result should be

stringBefore  stringAfter   

--------------------------------

Pen                red

PENCIL         GREEN

Thanks a lot!!

oracle version is:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

PL/SQL Release 11.2.0.4.0 - Production

"CORE 11.2.0.4.0 Production"

TNS for HPUX: Version 11.2.0.4.0 - Production

NLSRTL Version 11.2.0.4.0 - Production

Comments
Post Details
Added on Nov 14 2018
4 comments
4,941 views