RegExp oracle

Hi I have a requirement to write a query to just only retrieve number i
tried regexp_substr but no luck.


example data

1.1.test
1.2.testtt
1.3.tetsttt

i want to get only the number but not the string
the string should be eliminated.
please help
thanks.
Sarma VadlamaniprogrammeranalystAsked:
Who is Participating?
 
slightwv (䄆 Netminder)Connect With a Mentor Commented:
If the data is always as you have posted and you want everything up to the second period, this might be more efficient (regular expressions are an expensive operation):

substr(col1,1,instr(col1,'.',1,2)-1)
0
 
slightwv (䄆 Netminder) Commented:
If the expected results are:
1.1
1.2
1.3

Try this:
rtrim(regexp_substr(col1,'^[0-9.]*'),'.')
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Try this:

select regexp_substr ('1.3.tetsttt','[0-9]*\.[0-9]*') from dual;

result:

1.3

http://sqlfiddle.com/#!4/d41d8/40499
0
 
Sarma VadlamaniprogrammeranalystAuthor Commented:
thanks it is working.
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Great ;) Which solution was working when you wrote the thanks comment? You chose the comment after that one as a solution?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.