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!

regex pattern for not starting with specific word

Mustafa KALAYCIMay 5 2018 — edited May 7 2018

Hello everyone,

Maybe this is something very simple but I am stuck here! this is my sample text:  testdef I am looking for "def" that is not "test" before it. so if string contains "testdef" I don't want it but if it is "testAdef" then I want to get Adef (or just def) I tried this:

select regexp_substr('testdef', '[^test]def') from dual;

first it seems working but [^] pattern is just for char list so it is not checking for "test" word, it is checking for lettern t,e,s and t. so in this string:

select regexp_substr('testedef', '[^test]def') from dual;

I would like to get "edef" but since e is in [^] list, it returns null too. I just want any def just not placed a "test" word before it.

how can I do that?

thanks.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 4 2018
Added on May 5 2018
32 comments
5,461 views