Greg Cox
Greg Cox

Reputation: 227

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 ?

Upvotes: 5

Views: 6766

Answers (1)

Frank Schmitt
Frank Schmitt

Reputation: 30765

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.

Upvotes: 4

Related Questions