Aayush Rajopadhyaya
Aayush Rajopadhyaya

Reputation: 103

Substring extraction from a given string, Oracle

I need to extract a string from a given set of string. The string given is :

Data string 1 : LOAD TEST ABC,2146520,9856452147
Data string 2 : LOAD TEST:804749:9756325874

Here, the string set has a static value "LOAD TEST ABC" and "LOAD TEST", here i need to extract the string from the middle 2146520 and 804749 as an Id.

Upvotes: 1

Views: 28

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 520968

You might be able to use REGEXP_SUBSTR here with a capture group:

SELECT col, REGEXP_SUBSTR(col, '[,:](.+?)[,:]', 1, 1, NULL, 1) AS middle_num
FROM yourTable;

screen capture from demo link below

Demo

Upvotes: 1

Related Questions