PostgreSQL 9.3:将超过 100 个参数传递给“REPLACE”函数

PostgreSQL 9.3: Pass more than 100 arguments to `REPLACE` function

我将大约 1000 个参数传递给函数 REPLACE

示例

字符串包含一些值:

 Declare
        str1 varchar = '1,2,3,4.................1000';

现在我想用 "," 替换 , 我正在使用以下内容 脚本:

 SELECT REPLACE(str1,',','","');

但是出现错误:

错误详情:

cannot pass more than 100 arguments to a function

replace函数只能搜索一个字符串进行替换。您可以使用 regexp_replace 函数查找多个字符串。此示例将 ac 替换为空:

select regexp_replace('abc', '(a)|(c)', '', 'g');
-->
b

g选项代表全局,允许多次替换。请注意 regex_replace 可以查找多个字符串,但仍然仅限于一个替换字符串。