我想用OF替换OF单词的实例。我只希望这能够用完整的单词来工作。因此,不在L_OF,DOF,OFZ,DOFD,OF_L等上。Oracle上的regexp_replace完整的单词
我的代码工作如下,但最后一个字符串除外。
它返回:
("OF"*OF + 2)
...相反:
("OF"*"OF" + 2)
我怎样才能得到它的上一个工作中呢?
with stg as
(
select '(ofof+ol)' str from dual union all
select '(oof+ol+of)' from dual union all
select '(*of + 2)' from dual union all
select '(of*of + 2)' from dual
)
select str,
regexp_replace(upper(str), '(\W|^)(OF)(\W|$)', '\1"OF"\3') as str2
from stg
问题是缺少posix正则表达式中的lookarounds。我想要得到你想要的东西,你必须把它放在一个plsql过程中,循环或嵌套regexp_replace,然后在另一个替换中删除多余的引号。 – RLOG