最近更换了博客的代码高亮插件,以前用的是SyntaxHighlighter:代码格式:
<pre class="brush: php; gutter: true">
//代码区
......
</pre>
现在换成了Crayon Syntax Highlighter:
<pre class="lang_php decode_true">
//代码区
......
</pre>
代码高亮的区域不一样,又有很多文章需要改,好吧,mysql肯定有替换功能函数,于是找了一下mysql的replace()函数资料:

replace()函数语法:

update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');
实例:
mysql> SELECT REPLACE('www.yanue.net', 'www', 'map');
+----------------------------------------+
| REPLACE('www.yanue.net', 'www', 'map') |
+----------------------------------------+
| map.yanue.net |
+----------------------------------------+
1 row in set (0.00 sec)

因此一个函数可以replace()函数就十分方便的解决问题了:
UPDATE wp_posts 
SET post_content = REPLACE(post_content, '<pre class="brush: php; gutter: true">', '<pre class="lang_php decode_true">');
文章完.