postgresql varchar字段regexp_replace正则替换
admin
2023-05-21 13:42:38
0

1.替换目标
1).contact字段类型 varchar。
2).去掉字段中连续的两个,每个等号后面数字不同,effective_caller_id_name=051066824513,effective_caller_id_number=051066824513。

2.查询原字段内容

select contact
from pbx_agents
where contact ~ 'effective_caller_id_name=' limit 2

"{sip_append_audio_sdp=a=fmtp:18 annexb=no,call_timeout=60,effective_caller_id_name=051066824513,effective_caller_id_number=051066824513,cti_account=9,cti_agent_id=1102441276,cti_account_sid=5be394c3f8754bd89b9618937c687068,absolute_codec_string=\'OPUS,G729 (...)"
"{sip_append_audio_sdp=a=fmtp:18 annexb=no,call_timeout=60,effective_caller_id_name=051066824824,effective_caller_id_number=051066824824,cti_account=9,cti_agent_id=1103211003,cti_account_sid=4f3fae0e71b74bdaa3824e6ec7771815,absolute_codec_string=\'OPUS,G729 (...)"

3.查询语句验证替换

select regexp_replace(contact, '(effective_caller_id_name=\d+,)+?','','g')
from pbx_agents
where contact ~ 'effective_caller_id_name='

"{sip_append_audio_sdp=a=fmtp:18 annexb=no,call_timeout=60,effective_caller_id_number=051066824513,cti_account=9,cti_agent_id=1102441276,cti_account_sid=5be394c3f8754bd89b9618937c687068,absolute_codec_string=\'OPUS,G729\'}sofia/gateway/agentProxy/1102441276"
"{sip_append_audio_sdp=a=fmtp:18 annexb=no,call_timeout=60,effective_caller_id_number=051066824824,cti_account=9,cti_agent_id=1103211003,cti_account_sid=4f3fae0e71b74bdaa3824e6ec7771815,absolute_codec_string=\'OPUS,G729\'}sofia/gateway/agentProxy/1103211003"

4.执行替换操作

update pbx_agents set contact = regexp_replace(contact, '(effective_caller_id_name=\d+,)+?','','g')

where contact ~ 'effective_caller_id_name='

Query returned successfully: 3929 rows affected, 505 msec execution time.

5.查询验证替换

select contact
from pbx_agents

"{sip_append_audio_sdp=a=fmtp:18 annexb=no,call_timeout=60,cti_account=9,cti_agent_id=1100891004,cti_account_sid=23869df09f2f47f0ae80a7cbc45e5185,absolute_codec_string=\'OPUS,G729\'}sofia/gateway/agentProxy/1100891004"
"{sip_append_audio_sdp=a=fmtp:18 annexb=no,call_timeout=60,cti_account=9,cti_agent_id=1102081069,cti_account_sid=9f2c1574fcb5497994cb9b892aee0d1c,absolute_codec_string=\'OPUS,G729\'}sofia/gateway/agentProxy/1102081069"

相关内容

热门资讯

广西再通报车辆坠河事件,已致9... 广西环江毛南族自治县人民政府5月18日通报:截至2026年5月18日20时,河池环江“5·16”过桥...
基地启用,机器人有了国家级职业... 5月16日,国家人工智能应用中试基地(具身智能)在浙江杭州挂牌启用,机器人有了国家级职业技能训练场。...
墙上瓷片掉了怎么处理 1、墙面地面基层处理不干净、浇水湿润度不够、瓷砖背面的浮尘没有清理都会导致瓷砖与墙面粘结不紧,一段时...
墙上的白灰掉了怎么办 首先观察一下,是石灰掉了还是乳胶漆掉了,如果是石灰掉了,那么需要将整个石灰墙铲除,再重新做抹灰工作,...
微信鸿蒙版App获8.0.17... PChome 5月16日消息,微信鸿蒙版App已在华为应用市场发布8.0.17.38(8392998...
白色自喷漆可以喷墙面吗 如果说墙面掉漆的面积非常小,那么就可以用自喷漆进行修补;如果说掉漆的面积比较大的话,就不要用自喷漆进...
墙面潮湿起皮脱落怎么处理 假如墙体返潮掉皮的范围大,并且有多层发霉的状况,则先需把掉皮处铲除,再重新涂刷油漆处理。先将外层返潮...
卫浴台下盆换一个多少钱啊 卫浴台下盆的价格因品牌、材质、尺寸和款式等因素而异。一般来说,普通的陶瓷台下盆价格在 100 元至 ...
海思科首次公布重磅新药 III... 来源:市场资讯 (来源:求实药社) 海思科将在本次大会上首次披露 1 类新药 HSK39297 片对...
原创 独... 太阳系最大的天空海啸刚刚被科学家彻底破解了。 它长达6000km,像一堵无形的硫酸水墙,每4.9天绕...