我遇到以下正则表达式的问题
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)
修改
非信徒的截图
答案 0 :(得分: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;
然后才有效。