Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I wrote a query which splits a string and show me as a value I want using SUBSTR
SELECT SUBSTR ('imagelocation/r1.jpg', 15) AS image_location FROM dual
I am getting the output as r1.jpg but I only want the value to come as r1. Please help
If you want something more universal, regexp_replace might be of use.
SELECT regexp_replace('imagelocation/r1.jpg','^[^/]*/([^.]+).*$','\1') AS image_location FROM dual;
Add a comment
select SUBSTR ( 'imagelocation/r1.jpg', INSTR('imagelocation/r1.jpg', '/')+1, LENGTH('imagelocation/r1.jpg') - INSTR('imagelocation/r1.jpg', '.') - 1 ) AS image_location FROM dual
SUBSTR Function in Oracle
SQL Fiddle
Try this:
SELECT SUBSTR('imagelocation/r1.jpg',15,2) AS image_location FROM dual
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.