Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle REGEXP_REPLACE uppercase replacement string

I am attempting to uppercase the replacement string from my reg expression without success:

SELECT regexp_replace('src=/i/uie_v2/js','(/uie_v2/)',upper('\1')) from dual

returns 'src=/i/uie_v2/js'

I understand that upper cannot be used .. just showing as an example. Any ideas on how to achieve this ?

like image 338
Greg Cox Avatar asked Oct 06 '22 10:10

Greg Cox


1 Answers

AFAIK, you cannot do this directly, but you can take the string apart and rebuild it:

SELECT regexp_replace('src=/i/uie_v2/js','(.*)(/uie_v2/)(.*)', '\1') ||
  upper(regexp_substr('src=/i/uie_v2/js','(/uie_v2/)')) || 
  regexp_replace('src=/i/uie_v2/js','(.*)(/uie_v2/)(.*)', '\3')
from dual

I got the idea from an OTN forums thread on REGEXP.

like image 51
Frank Schmitt Avatar answered Oct 10 '22 02:10

Frank Schmitt