Solved

Parsing .. using REGEXP_SUBSTR

Posted on 2009-04-14
9
570 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 74

Expert Comment

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

?
0
 
LVL 74

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 74

Expert Comment

by:sdstuber
ID: 24146872
glad I could help, please close the question
0
 

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 74

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 74

Expert Comment

by:sdstuber
ID: 24152624
glad I could help
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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 video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

734 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