【发布时间】:2016-06-13 13:55:31
【问题描述】:
我正在使用以下查询将值 2 替换为 5。我的输入字符串将采用如下所示的格式。每个值将用胡萝卜(^)符号分隔。当没有重复值时它工作正常。但是对于重复的值,它不起作用。请指教。
select regexp_replace('1^2^2222^2','(^|\^)2(\^|$)','\15\2') OUTPUT from dual;
输出:
1^5^2222^5 ( Working Fine as there is no consecutive duplicates at the starting or at the end)
.
select regexp_replace('2^2^2222^2^2','(^|\^)2(\^|$)','\15\2') OUTPUT from dual;
输出:
5^2^^5^2222^5^2(Not working as there is consecutive duplicate at the starting/end)
请告诉我如何纠正这个问题?
【问题讨论】:
-
你想要的输出的规则是什么?
-
^符号是 caret。 -
谢谢。以后会保证的
标签: sql oracle oracle11g regexp-replace