How to Number Seprated By Any Character in Oracle

Posted By  Nimish Garg On 17 Jun 2011 09:06:18
emailbookmarkadd commentsprint
No of Views:737
Bookmarked:0 times
Votes:0 times

Introduction

In this tip, I am going to explain to how to separate number separated by any characters in Oracle Database.

Implementation

The implementation is simple and easy, let take look following example string number is contains with different characters

Value: '374627467(92876/5674)988276+87234687/8974232*3746-984027374[32742-3746236'

Let's see how to separate each number portion from above string using function. Before we write code assume what would be expected results to above string.

Expected Output:

VALUE
------------
374627467
92876
5674
988276
87234687
8974232
3746
984027374
32742
3746236

PL/SQL Script

with t as (
select '374627467(92876/5674)988276+87234687/8974232*3746-984027374[32742-3746236' x from dual
)
select
    substr(   
        ','||x,regexp_instr(','||x,'[^[:digit:]]',1,level)+1,
        regexp_instr(x||',','[^[:digit:]]',1,level) - regexp_instr(','||x,'[^[:digit:]]',1,level)
    ) value
from
    t connect by level <= length(x) - length(regexp_replace(x,'\D')) + 1;

Hope helps and thank you for reading.

Sign Up to vote for this article
Other popular Tips/Tricks
Comments
By:NitinDate Of Posted:5/25/2010 6:13:21 PM
Notification..
Hi, Thank you for the article. I am trying to do something like this in WinForms. I would like to display notification when new mail is arrived. Any idea how to do it? Thank you Nitin
By:NitinDate Of Posted:5/25/2010 6:12:23 PM
Notification..
Hi, Thank you for the article. I am trying to do something like this in WinForms. I would like to display notification when new mail is arrived. Any idea how to do it? Thank you Nitin
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top