0

我对以下正则表达式有疑问

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)

编辑:

非信徒截图
在此处输入图像描述

4

1 回答 1

0

想通了我自己的问题£,我相信每个人都怀疑

解决方案包含两个步骤首先是获取符号代码,即使你复制粘贴£进去select ascii() from dual也不行。您必须选择如下符号才能获得正确的代码。

select ascii(substr(declinereasondesc, 30,1)) from DECLINEREASON t
where declinereasonid = 7;

就我而言,它给了49827

然后

select REGEXP_REPLACE(declinereasondesc, '(.+)('||chr(49827)||')(\d+)', '\1\3 (GBP)') from DECLINEREASON t;

只有这样它才能工作。 在此处输入图像描述

于 2014-11-19T12:05:16.870 回答