Avatar of bmsande
bmsande
 asked on

Oracle Regex to extract substring between two patterns

I have a column where I need to extract a string that sits between two patterns.  The string is as follows:

A<1,?,'providerInfo'='0003\\370\\3370288.dat','storageProviderName'='ExtShared','subProviderName'='Default'>

Open in new window


And I need to extract the embedded file path

0003\\370\\3370288.dat

Open in new window


Bonus points if you can also replace the \\ with \
DatabasesOracle DatabaseSQL

Avatar of undefined
Last Comment
slightwv (䄆 Netminder)

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
slightwv (䄆 Netminder)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
slightwv (䄆 Netminder)

If you don't care about the delimiter and only want that specific pattern then try this:
with mydata as(
select q'[A<1,?,'providerInfo'='0003\\370\\3370288.dat','storageProviderName'='ExtShared','subProviderName'='Default'>]' mycol from dual
)
select replace(regexp_substr(mycol,'[0-9\]+\.[a-z]{3}'),'\\','\') from mydata
/

Open in new window

Sean Stuber

SELECT REPLACE(
           REGEXP_SUBSTR(
               yourstring,
               q'['providerInfo'='(.*)','storageProviderName]',
               1,
               1,
               NULL,
               1
           ),
           '\\',
           '\'
       )
  FROM (SELECT q'[A<1,?,'providerInfo'='0003\\370\\3370288.dat','storageProviderName'='ExtShared','subProviderName'='Default'>]'
                   yourstring
          FROM DUAL)
bmsande

ASKER
Worked beautifully.  I award you 1 trillion bonus points.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
slightwv (䄆 Netminder)

Glad to help!