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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

regexp_substr with multiline text: how to return the next line

user3292382Oct 9 2018 — edited Oct 9 2018

I have a multiline text, structured like a windows .INI file (with sections enclosed in square brackets and pairs of keys and values).

I want to search for a particular section and return the line next to that section, that is the first line of values.

example:

[Planets]

Moon=30

Sun=34

[Animals]

Lion=564

Mouse=34

So, if I search for "[Planets]" I want the first line: "Moon=30".

If I search for "[Animals]" I want "Lion=564".

I believed to use the regexp_substr function, with two section, multiline, and return the second occurrence, but it fails.

Here is what I've done:

select regexp_substr(myText,'(\[Planets\].*$)(.*)',1,1,'m',2)

from myTable

What I have to do?

Thank you in advance.

Comments
Post Details
Added on Oct 9 2018
7 comments
6,306 views