Oracle REGEXP_REPLACE uppercase replacement string

大憨熊 提交于 2020-02-23 19:07:52

问题


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 ?


回答1:


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.



来源:https://stackoverflow.com/questions/12726450/oracle-regexp-replace-uppercase-replacement-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!