SQL Language (MOSC)

MOSC Banner

Unexpected output from REGEXP_SUBSTR

edited Nov 14, 2019 6:42AM in SQL Language (MOSC) 3 commentsAnswered

I have two strings:

RP.MOC.00012B.SM.01

123-456-7890

I am running following SQL statements:

SELECT REGEXP_SUBSTR('RP.MOC.00012B.SM.01', '.[^.]+') "REGEXP_SUBSTR" FROM dual;

SELECT REGEXP_SUBSTR('123-456-7890', '-[^-]+') "REGEXP_SUBSTR" FROM DUAL;

Output of 1st query is RP and output of 2nd query is -456

As per guide and my understanding output of 1st query should be .MOC however if I replace . with - in 1st query, -MOC is appearing but with . output is RP

I want to know what is the reason for this different behaviour of query.

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center