Regex Postgresql替换所有出现的字符串+;
我有这个字符串:Regex Postgresql替换所有出现的字符串+;,regex,postgresql,regexp-replace,Regex,Postgresql,Regexp Replace,我有这个字符串: this is the abcd xxx string I want to abcd yyy replace in my text abcd zzz 现在我想将abcd及其后的任何内容替换为空白 我想要这个结果: this is the string I want to replace in my text 我试过: select regexp_replace(str, 'abcd.*','','gi') 但是在第一场比赛之后,它就把一切都移除了。还有其他没有运气的组
this is the abcd xxx
string I want to abcd yyy
replace in my text abcd zzz
现在我想将abcd
及其后的任何内容替换为空白
我想要这个结果:
this is the
string I want to
replace in my text
我试过:
select regexp_replace(str, 'abcd.*','','gi')
但是在第一场比赛之后,它就把一切都移除了。还有其他没有运气的组合
我错过了什么
谢谢 使用
regexp\u replace()
中的标志n
(换行符敏感匹配):
with my_table(str) as (
values(
'this is the abcd xxx
string I want to abcd yyy
replace in my text abcd zzz')
)
select regexp_replace(str, 'abcd.*','','gin')
from my_table
regexp_replace
-----------------
this is the +
string I want to +
replace in my text
(1 row)