REGEXP_REPLACE to replace everything except specific words?
964459Sep 26 2012 — edited Sep 28 2012Hi,
I want to replace everything in a column with NULL, except some specific words.
/
create table test_regexp_replace
as
select 'trunc (sysdate ) >= trunc ( claim_entry_date + 18 )' as str from dual
union
select 'trunc (claim_entry_date+7) <trunc ( sysdate )' from dual
union
select 'sysdate < claim_entry_date +12' from dual
/
In STR column I want to delete every character/word except : 'claim_entry_date', 'sysdate', +,-,>,<,=,[[:digit:]]
I tried to use the following regexp_replace, but it doesn't work
/
select
str,
regexp_replace ( str, '[^(claim_entry_date)|[[:digit:]]|<|>|>|<|=|\+|-|(sysdate)]', '') regexp_str
from
test_regexp_replace
/
I want to have my result set looks like the following:
REGEXP_STR
sysdate>=claim_entry_date+18
claim_entry_date+7<sysdate
sysdate<claim_entry_date+12
Is it possible to acheive this with Oracle regexp?
Thanks
ilke
Edited by: 961456 on 26.09.2012 02:22
Edited by: 961456 on 26.09.2012 02:22