正则表达式 – 正则表达式在Postgres中查找和替换
发布时间:2020-12-14 06:37:02 所属栏目:百科 来源:网络整理
导读:我有一个表格,其中包含一列包含URL的行。网址的格式如下: http://one.example1.com:9999/dotFile.com 我想用http://example2.com/dotFile.com替换该列中的所有匹配项,同时保留以下所有内容:9999。我已经找到一些关于regexp_matches和regexp_replace的文
我有一个表格,其中包含一列包含URL的行。网址的格式如下:
http://one.example1.com:9999/dotFile.com 我想用http://example2.com/dotFile.com替换该列中的所有匹配项,同时保留以下所有内容:9999。我已经找到一些关于regexp_matches和regexp_replace的文档,但是我不能很好地围绕它。
如果你知道url,你不必使用正则表达式。 replace()函数应该适用于你:
replace(string text,from text,to text) Replace all occurrences in string of substring from with substring to example: replace('abcdefabcdef','cd','XX') abXXefabXXef 你可以试试: replace(yourcolumn,'one.example1.com:9999','example2.com') (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |