通过regex用回调替换内容标记
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过regex用回调替换内容标记相关的知识,希望对你有一定的参考价值。
/** * Replace all tags matching a regexp with value of callback function * (passes grouped subpatterns to callback as params) */ function my_wp_plugin_tag_action($content,$tag,$function,$args = FALSE) { // match all regular expressions // filter duplicates // loop through foreach ($matches as $idx => $match) { //build arg array //call function, adding function output and full tag text to replacement array $tag_results[] = my_wp_plugin_buffer_func($function,$match); $found_tags[] = $full_tag; } // replace all tags with corresponding text } return $content; }
以上是关于通过regex用回调替换内容标记的主要内容,如果未能解决你的问题,请参考以下文章