coolcode转SyntaxHighlighter与Mysql正则表达式

blog的代码高亮插件原来是coolcode的,coolcode的高亮插件确实很酷,显示效果也很棒,但是占用的位子太大了。最近,我抽空改成SyntaxHighlighter。由于coolcode插件的开头标签是

<coolcode>

或者[coolcode]这样的,而SyntaxHighlighter是

1。
mysql里执行两句sql即可

UPDATE wp_posts SET post_content = REPLACE(post_content,'</coolcode>','[\/code]');  //注意后面多了个反斜杠,记得去掉
UPDATE wp_posts SET post_content = REPLACE(post_content,'[/coolcode]','[\/code]');  //注意后面多了个反斜杠,记得去掉

总结:
本文牵扯的正则表达式并无高级用法,都是平常很简单的用法。关于PCRE引擎正则表达式的递归(迭代),组命名,反向引用,零宽断言等,CFC4N会在以后的时间里,找合适的例子写出来。当然,这些高级用法,CFC4N在帮朋友写的正则表达式里已经用到了,大家可以看看,欢迎批评和指点。
PS:如果需要coolcode转SyntaxHighlighter的完整PHP程序,留言即可,我抽空写出来。

您可能喜欢下面几篇博文

发表评论

4 Comments.

  1. 貌似好复杂~~

  2. @Junan
    慢慢研究正则,还是挺有意思的哈。

  3. 你用来验证正则的工具是什么啊? :grin:

Leave a Reply



[ Ctrl + Enter ]

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

CNXCT小组的博客 is Stephen Fry proof thanks to caching by WP Super Cache