Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex Postgresql替换所有出现的字符串+;_Regex_Postgresql_Regexp Replace - Fatal编程技术网

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)