0

I have the data below,Is any way to write common regular expression to get desired output in oracle using regexp_replace function.

<Tier><grade><><sdlc><17,10><>  : result should be 17.10
<><sdlc><16,909312> :   16.909312
<><sdlc><11396,87> :11396.87
<20121217>        :20121217
<UNIT><6086>  : 6086
<Tier1><><sdlc><0,47> :0.47
user1726550
  • 83
  • 1
  • 4
  • 14
  • Thanks Reimeus,But i want it using regular expression,that is the limitation i have it. – user1726550 Dec 18 '12 at 22:34
  • 1
    Is your data XML ? if so, better read this- http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – A.B.Cade Dec 18 '12 at 22:43
  • @shellter His question is quite clear. `<><17,10><>` convert to `17.10` – Smit Dec 18 '12 at 22:49
  • @shellter It happens cuz we just took brief look and miss details. Happens to best of us. ;-} – Smit Dec 18 '12 at 22:54

1 Answers1

2

You could you a simple regex like below:

Steps:

  • Replace , witha .
  • use regex to find a match

Code:

String s="<Tier><grade><><sdlc><17,10><>";
            s = s.replace(',', '.');
            Pattern p = Pattern.compile("\\d+\\.*\\d+");
            Matcher m = p.matcher(s);
            if(m.find()){
            System.out.println(m.group());// 17.10
        }
PermGenError
  • 45,977
  • 8
  • 87
  • 106