sql - 如何删除 PostgreSQL 中两个字符之间的字符串?
问题描述
我有一列包含地址信息。我想删除 和 之间的所有内容#
,,
但也要删除#
并离开,
.
编辑:我还需要删除#
.
这是我的专栏的样子:
ADDRESS
123 abc st. #123, city, zipcode
321 def road #321, city, zipcode
所以我的专栏看起来像这样:
ADDRESS
123 abc st., city, zipcode
321 def road, city, zipcode
解决方案
根据您的示例,您还希望删除之前的空格#
:
select str, regexp_replace(str, ' #[^,]+,', ',')
from (values ('321 def road #321, city, zipcode')) v(str)
推荐阅读
- gstreamer - Gstreamer 无法播放视频
- opengl - 如何设置灯光和材质以获得翡翠物体
- elasticsearch - 有什么方法可以汇总没有异常值的弹性平均值?
- javascript - 如何检测所选文本是否在可编辑区域中?
- reactjs - NextJS Netlify 构建失败,节点版本为“12.18.3”
- jquery - 在多个浏览器中加载数据库内容而不刷新
- java - g1 gc 写屏障:异或和移位
- html - 如何在更改另一个下拉 jquery 中的任何值时显示具有某些值的新下拉列表
- java - 如何在春季更改属性源位置?
- winforms - .NET 5 WinForms 应用程序中保存的设置在哪里?