replacing square brackets of a string with oracle REGEXP_REPLACE function

后端 未结 3 1718
离开以前
离开以前 2020-12-04 04:37

I want to replace square brackets in string with REGEXP_REPLACE function. Even I escape these chracters it\'s not replacing

select regexp_replace(\'VMI[[DATA         


        
3条回答
  •  时光取名叫无心
    2020-12-04 04:59

    You can do it like this:

    select regexp_replace('VMI[[DATA]]INFO', '\[|\]', '_') from dual;
    

    But I don't think that regular expressions are needed here, you can also use TRANSLATE

    select translate('VMI[[DATA]]INFO', '[]', '__') from dual;
    

    Here is a sqlfiddle demo

提交回复
热议问题