网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

postgresqlvarchar字段regexp_replace正则替换

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

创新互联主营常州网站建设的网络公司,主营网站建设方案,app软件开发,常州h5微信平台小程序开发搭建,常州网站营销推广欢迎常州等地区企业咨询

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"


网页标题:postgresqlvarchar字段regexp_replace正则替换
当前URL:http://bjjierui.cn/article/ieoooi.html

其他资讯