Oracle Regular Expression [message #405139] |
Tue, 26 May 2009 08:39 |
vipinsonkar2000
Messages: 38 Registered: May 2008
|
Member |
|
|
Hi All,
I need to select only those records which have either numeric value or : or both (numeric and :).
create table oss_test_vip ( x varchar2(10) )
select x
from oss_test_vip
where not REGEXP_LIKE(x,'(^[[:digit:]*[:]*]*$)')
Problem is that above query also discarding NULL value too.
Please help me out.
[Updated on: Tue, 26 May 2009 08:40] by Moderator Report message to a moderator
|
|
|
|
Re: Oracle Regular Expression [message #405177 is a reply to message #405139] |
Tue, 26 May 2009 13:58 |
|
ebrian
Messages: 2794 Registered: April 2006
|
Senior Member |
|
|
Be careful with your regex, it will also select rows with digits, colons AND/OR astericks '*' and brackets '[]'.
You could rewrite it as:
select x
from oss_test_vip
where REGEXP_LIKE(x,'^[[:digit:]:]*$') ;
Also didn't know why you used WHERE NOT when you actually wanted those rows ?
[Updated on: Tue, 26 May 2009 14:16] Report message to a moderator
|
|
|