Solved

Parsing .. using REGEXP_SUBSTR

Posted on 2009-04-14
9
565 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
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.

 
LVL 73

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 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.

Question has a verified solution.

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

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
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…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

821 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