查了一下网上,普遍给出如下解决方案:
update comment set author_url=REPLACE(author_url, ’sohu’, ’sina’) where author_url REGEXP “www.sohu.com”;
但是问题是被替换的字符串内容不定,以上办法就不行了。
在开发反向链接交换网的时候也碰到类似问题,最后想出了一个办法,结合使用locate函数:
$l=strlen($….)
update table set words = replace(words, substring(words, locate(’part_of_words’, words),”.$l.” ), ”)
Filed under:
网络营销
Leave a comment