我想从
删除(Apple Banana)String ='我买了Apple,Banana,Orange和Mango'
NewString ='我买了,Orange和Mango'
答案 0 :(得分:0)
这个怎么样?
select replace(
replace('I bought Apple , Banana , Orange and Mango', 'Apple'),
'Banana')
from dual;
或
declare
my_string varchar2(50) := 'I bought Apple , Banana , Orange and Mango';
begin
my_string := replace(replace(my_string, 'Apple'), 'Banana');
end;
答案 1 :(得分:0)
使用REGEXP_REPLACE避免将多个替换函数链接在一起。
SELECT
REGEXP_REPLACE(my_string, 'Apple|Banana', '')
FROM
my_table
答案 2 :(得分:0)
select regexp_replace(source_string, '(^|\W)(Apple|Banana)(\W|$)', '\1\3', 1, 0, 'i') as new_string
from (select 'I bought Apple , Banana , Orange and Mango' as source_string
from dual);
NEW_STRING
I bought , , Orange and Mango
此代码取代整个单词“Apple”或“Banana”不区分大小写。
答案 3 :(得分:0)
我会尝试这样的事情
选择替换(替换('我买了苹果,香蕉,橙和芒果','苹果'),'香蕉') 来自双重;