【发布时间】:2014-02-26 04:21:49
【问题描述】:
我在我的 WordPress 语法代码高亮中使用了 preg_match_all 单引号 ',它正在工作
preg_match_all("/'(.*?)'/",$content,$matches);
但是当我在这段代码中使用双引号 " 时,它不起作用
preg_match_all('/"(.*?)"/',$content,$matches);
有没有简单的方法来修复代码?
--编辑--
我正在使用此代码制作我自己的 wordpress 语法高亮代码插件
function myHighlightSyntaxCode($content )
{
global $post;
$content= $post->post_content;
$content=reformatText($content);
return $content;
}
function reformatText($content){
preg_match_all("/'(.*?)'/",$content,$matches);
/*
this is the part of my code for content inside quote
*/
}
add_filter( 'the_content', 'myHighlightSyntaxCode');
【问题讨论】:
-
您能否向我们展示
$content的示例以及您希望在$matches中找到什么? -
是的,你可以在我的博客上看到:) blog.imammubin.com/…
标签: php wordpress preg-replace preg-match-all