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!

regexp_substr {}

vijaypMay 16 2020 — edited May 18 2020

Oracle Database 11g 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 Linux: Version 11.2.0.4.0 - Production

NLSRTL Version 11.2.0.4.0 - Production

Could you please help me to understand why my repeater does not work.

it is my understanding that any sub expression that precedes {2} gets executes 2 time.

-- Want output as : 9567993B-3BE1 , Get first (9567993B) and second (3BE1 ) String

select regexp_substr('9567993B-3BE1-4480-B64A-ADFAD4CA5887' ,'([^-]+){2}',1, 1) from dual;


--[^-]* -- match any character other than -
--{2} repeater above search 2 timesĀ 
-- 1 Start Searching at Position one in the string .
-- 1 Return the output of the match.

Below works .

select regexp_substr('9567993B-3BE1-4480-B64A-ADFAD4CA5887' ,'[^-]*-[^-]*',1,1) from dual;

This post has been answered by mathguy on May 16 2020
Jump to Answer
Comments
Post Details
Added on May 16 2020
6 comments
604 views