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.

Extracting specific portion of a string using REGEX

buggleboy007Apr 6 2020 — edited Apr 7 2020

I have a string(or two records) of the type:

a) C:\Users\user1\Pictures\1.JPG

b) C:\Users\user1\Pictures\file_example_TIFF_1MB.tiff

I am using the following query to extract the name of the file and I am only able to pull the 1st record out (1.JPG).

When I use this:

select dt, seq, message,REGEXP_SUBSTR(message,  '[0-9]+(.JPG|.TIFF|.tiff)+')

from log_output_table where seq in (23438852,23438853); 

Output is only : 1.JPG

When I use this:

select dt, seq, message,REGEXP_SUBSTR(message,  '[[:alnum:]]+(.JPG|.TIFF|.tiff)+')

from log_output_table where seq in (23438852,23438853); 

Output is:

1.JPG

example_TIFF

How can I pull both - first and second (1.jpg and file_example_TIFF_1MB.tiff) including any file extension (whether upper or lower case).

This post has been answered by mathguy on Apr 6 2020
Jump to Answer

Comments

Post Details

Added on Apr 6 2020
13 comments
3,505 views