这是Fiddle。
所需输出
Buy flood insurance. Act now.
Buy flood insurance. Call now.
Buy flood insurance. No change.
这是我的尝试:
with data_row as (
select 'or buy flood insurance. Act now.' as disclaimer from dual union all
select 'or Buy flood insurance. Call now.' as disclaimer from dual union all
select 'Buy flood insurance. No change.' as disclaimer from dual )
select case
when regexp_like(disclaimer,'^or (B|b)uy flood insurance.*') then
regexp_replace(disclaimer,'^or (B|b)uy flood insurance.*','Buy flood insurance.')
else disclaimer
end as revised
from data_row
答案 0 :(得分:1)
只需使用like
与lower()
一起查找需要更改的内容,并在需要时使用硬编码大写覆盖B
:
select
case
when lower(message) not like 'or b%' then message
else 'B' || substr(message, 5)
end message
from disclaimer
请参阅SQLFiddle