I have table T with sample data below. The data has occurences of phrace "ab" several times, several places. I want to replace LAST occurence of "ab" with value "ab_last". How to write such query?
with T as
(
select 'some symbols
ab cd
lot of occurences of ab here
this is last ab occurence: ab
some more symbols ' s from dual
)
select REGEXP_REPLACE(T.s, '([^ab.]+)','\1_last;') as s from T
/*
END some sym_last;bols
ab cd
lot of occurences of ab here
this is last ab occurence: ab
some more symbols
*/
I think Oracle doesn't have function "ReplaceLast". And regular expressions cannot specify filter "last of" as i understand. So how to write the query?
Expected result:
'some symbols
ab cd
lot of occurences of ab here
this is last ab occurence: ab_last
some more symbols '
--
I have version 10g.