实现了用正则表达式批量替换更新数据库数据

update d_blog d set d.info_source=REGEXP_REPLACE(d.info_source,'(blog/static.*?){2}$', 'blog//1') where d.info_source like '%static%static%'
数据库中字段是这样的:
http://blog.163.com/dangguoyingblog/static/481206532009410104046151blog/static/481206532009410104046151
更改后是这样的:
http://blog.163.com/dangguoyingblog/blog/static/481206532009410104046151

正则真是个好东西啊。哈哈哈哈哈哈哈

 

 

 

select regexp_replace('e:/fs_root/images/host_21_wangyiblog/2009/11/30/14/00/2009113014000560.jpg','e:/fs_root/(.*?)/[^/.]*?.jpg','//1/') from dual;

 

 

update c_pic_logo_n set location=regexp_replace(location,'^e:/fs_root/(.*?)/[^/.]*?.jpg$','//1/') where id=4471;

 

 

 

before ti huan
e:/fs_root/images/host_21_wangyiblog/2009/11/30/14/00/2009113014000560.jpg
arger ti huan
/images/host_21_wangyiblog/2009/11/30/14/00/

 

你可能感兴趣的:(數據庫)