tonyf
tonyf

Reputation: 35557

Retrieving certain strings within a string using Oracle SQL - Part 2

Unfortunately I having a few issues now trying to get this going as my data has changed based on an original thread I started see:

Retrieving certain strings within a string using Oracle SQL

My data has now changed to look like:

member_of = CN=DAaXYZApple-Au, CN=DAaXYZApple-Readonly, CN=aXYZApple-Write, CN=DAaXYZApple-Au-Admin, CN=aTest123_RW, {CN=# XXY22,} CN=aInternet-1

Using the same type of techniques described in my original post, I need to obtain all strings that hold the string "aXYZApple" only. So based on the above, the following results is what I am after and would be displayed only:

aXYZApple-Au
aXYZApple-Readonly
aXYZApple-Write
aXYZApple-Au-Admin

I am unsure if I still need to use Oracle regexp_substr as in my original post.

Upvotes: 0

Views: 216

Answers (1)

tonyf
tonyf

Reputation: 35557

The solution for my own question based on updated dataset is as follows, which is pretty much based on the solution provided to me in my original question, i.e.:

SELECT regexp_substr(line, 'aXYZApple[^,]*') subtxt
FROM (SELECT regexp_substr(:x, '[^,]*\,', 1, rownum + 1) line
      FROM dual
      CONNECT BY LEVEL <= length(:x) - length(REPLACE(:x, ',', '')))
WHERE line LIKE '%aXYZApple%';

Upvotes: 1

Related Questions