Solved

Parsing .. using REGEXP_SUBSTR

Posted on 2009-04-14
9
558 Views
Last Modified: 2013-12-18
Hi Experts -
I am trying to parse the following string
my input
(KEYWORD . . . . . CodeWord.  xyz8397G3 (54321) AND 7586806(06789))
My output should be
KEYWORD . . . . . someString. xyz8397G3 (54321) AND 7586806(06789)

I am trying to retrieve every thing between starting parenthesis and ending parenthesis.

regards
0
Comment
Question by:akp007
  • 5
  • 4
9 Comments
 
LVL 73

Expert Comment

by:sdstuber
ID: 24143536
what happened to "CodeWord.  "  that it turned into "someString."

?
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
ID: 24143552
I don't understand your example, but to satisfy the description...
"I am trying to retrieve every thing between starting parenthesis and ending parenthesis."


don't use regexp_substr  use regexp_replace instead


regexp_replace(your_string_here,'(^\()(.*)(\)$)','\2')
0
 

Author Comment

by:akp007
ID: 24144208
Thanks so much. your solution is perfect.  
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 24146872
glad I could help, please close the question
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:akp007
ID: 24151863
I will close it. Can I ask you question before that. If you have some time to spare, can you please explain the solution

(KEYWORD . . . . . CodeWord.  xyz8397G3 (54321) AND 7586806(06789))

regexp_replace(your_string_here,'(^\()(.*)(\)$)','\2')

What I would like to know, where the outer parenthesis are being replace in this logic

Regards
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 24152042
sure,
the expression is in 3 parts...

1 - (^\()   - which means start with open parentheses
2 -(.*)   - which means anything
3- (\)$) - which means ends with parentheses


the \2 replacement means replace the entire expression with the 2nd part of the expression
so, it's not so much that the parentheses are being replaced with something rather they are not included
0
 

Author Comment

by:akp007
ID: 24152564
Thank you
0
 

Author Closing Comment

by:akp007
ID: 31570163
Very fast and acuurate solution provided by sdstuber. Great
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 24152624
glad I could help
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now