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

x
?
Solved

RegExp oracle

Posted on 2015-02-08
5
Medium Priority
?
136 Views
Last Modified: 2015-02-09
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.
0
Comment
Question by:Sarma Vadlamani
  • 2
  • 2
5 Comments
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40597386
If the expected results are:
1.1
1.2
1.3

Try this:
rtrim(regexp_substr(col1,'^[0-9.]*'),'.')
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40597391
Try this:

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

result:

1.3

http://sqlfiddle.com/#!4/d41d8/40499
0
 

Author Comment

by:Sarma Vadlamani
ID: 40598162
thanks it is working.
0
 
LVL 78

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 total points
ID: 40598196
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
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40598308
Great ;) Which solution was working when you wrote the thanks comment? You chose the comment after that one as a solution?
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
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, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to recover a database from a user managed backup

782 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