Solved

Parsing .. using REGEXP_SUBSTR

Posted on 2009-04-14
9
569 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
Technology Partners: 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

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!

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

756 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