Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Parsing .. using REGEXP_SUBSTR

Posted on 2009-04-14
9
Medium Priority
?
589 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 74

Expert Comment

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

?
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
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 take different types of Oracle backups using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
Suggested Courses

971 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