如何REGEXP_REPLACE特殊字符 [英] How to REGEXP_REPLACE special character
本文介绍了如何REGEXP_REPLACE特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对以下正则表达式有疑问
I am having issue with following regex
select REGEXP_REPLACE(declinereasondesc, '(.+)(£)(\d+)', '\1\3 (GBP)') as r from DECLINEREASON t
它与以下几行不匹配
Too expensive : By less than £100
Too expensive : By more than £200
预期结果
Too expensive : By less than 100 (GBP)
Too expensive : By more than 200 (GBP)
非信徒的屏幕截图
screenshot for non-believers
推荐答案
弄清楚我自己的问题是£
,因为我确定每个人都怀疑
Figured it out myself problem is £
as I am sure everyone suspected
解决方案包含两个步骤,第一步是获取符号代码,即使将粘贴£
复制到select ascii() from dual
中也不会飞行.您必须选择如下所示的符号才能获得正确的代码.
Solution contains two steps first is to get symbol code, even if you copy paste £
into select ascii() from dual
it does not fly. You have to select the symbol like following to get correct code.
select ascii(substr(declinereasondesc, 30,1)) from DECLINEREASON t
where declinereasonid = 7;
在我的情况下,它给出了49827
In my case it gave 49827
然后
select REGEXP_REPLACE(declinereasondesc, '(.+)('||chr(49827)||')(\d+)', '\1\3 (GBP)') from DECLINEREASON t;
,然后它才起作用.
and only then it works.
这篇关于如何REGEXP_REPLACE特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文