Link to home
Start Free TrialLog in
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 \
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of slightwv (䄆 Netminder)
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

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)
Avatar of bmsande

ASKER

Worked beautifully.  I award you 1 trillion bonus points.