在Postgres中查找多个字符串并替换为单个字符串 [英] Find multiple strings and replace with single string in Postgres
本文介绍了在Postgres中查找多个字符串并替换为单个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用以下内容进行查找和替换?
Is it possible to do a "find and replace" with the following?
UPDATE __table__ SET __column__ = replace(__column__, ' ', '_');
如何定义要查找的字符串数组(','
,';'
,':'
,''
)替换为'_'
?
How do I define an array of strings to be found (','
, ';'
, ':'
, ' '
) to replace with '_'
?
推荐答案
阅读有关括号表达式的部分解释了如何在字符串中搜索要替换的字符
Read the section about Bracket Expressions which explains how to search for characters within a string to replace
但这应该对您有用
UPDATE __table__ SET __column__ = regexp_replace( __column__, E'[\\s,;:]','_','g')
这篇关于在Postgres中查找多个字符串并替换为单个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文