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.

preferred match from regexp_instr

user4079215Feb 24 2025

Hello - I am trying to find a way to search for several possible terms using regexp_instr but preferentially return the starting position of a preferred term.

I may not be constructing the regexp below properly or efficiently, but assuming it is valid, here is an example of what I am trying to do.

regexp_instr(NOTE_TXT,'final\s{1,4}decision\S*\s*',1,1,0,'i')

Terms that could be present in NOTE_TXT ("final' can be followed by 1 - 4 spaces):

final decisions final decision: final decision

Any of these terms could be present or absent, and in any order. But if a term is present, it typically appears only once. The term “final decisions” is preferred and is always directly followed by useful text. Term “final decision:” may also be present but is typically followed by less useful text. Term “final decision” is rarely followed by any useful verbiage.

Is there a way to use Oracle's regexp_instr in the way I am envisioning? Thanks for any ideas or opinions on this question.

Comments
Post Details
Added on Feb 24 2025
8 comments
187 views