INSTR search for NOT a number.

Basically, I'm extracting some data from from a CLOB.  I know the starting point, but the end point is unkown.  It is when the number ends.  I was first assuming that there was a space so had the following code

(substr(clbtext, instr(clbtext,'DS-',1), instr(clbtext,' ',instr(clbtext,'DS-',1)))) as test

But it could also be a full stop or an end of line.  And possibly ones I dont' know of.

So, I'm wondering can I extract the text from the starting point until the number ends.
So, what I am looking for will always start with 'DS-'  Can be followed by a two or three letter string and another dash e.g. 'TST-', then the 4 digit number

So what I'm looking to do is something like:

(substr(clbtext, instr(clbtext,'DS-',1), instr(clbtext,'NOT A NUMBER',instr(clbtext,'DS-',1)+7))) as test

How can I go about achieving this?
Who is Participating?
sdstuberConnect With a Mentor Commented:
try this...


I made the assumption that your 2 or 3 letter string would always be capital letters

if not

then change


Alexander Eßer [Alex140181]Software DeveloperCommented:
just a thought:

how about using RegExp as shown here:

you might use REGEXP_SUBSTR in conjunction with "[:digit:]"...
Alexander Eßer [Alex140181]Software DeveloperCommented:
If you're running 9i, you could use one of the custom regexp functions found throughout the web, like

or just google it ;-)
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

obrienjimmyAuthor Commented:
Brilliant, works perfectly.  Times like this I realize how little I know about Oracle.
Alexander Eßer [Alex140181]Software DeveloperCommented:
it's rather more about using RegExp than using Oracle ;-)
obrienjimmyAuthor Commented:
I know.  I only work with oracle / code in plsql every now and again, not part of my main job.  I've only used regexp once before I think. I need to learn more about it, it obviously is very useful.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.