【发布时间】:2012-09-26 22:02:09
【问题描述】:
我需要捕获 2 个组:1-expr(可以为空); 2-essi
见下面的代码
$s = 'regular expr<span>essi</span>on contains';
function my_func($matches){
//I need 2 groups captured
//$matches[1] - "expr" (see $s before span) - can be empty, but I still need to capture it
//$matches[2] - "essi" (between spans)
}
$pattern = "???";
echo preg_replace_callback($pattern, my_func, $s);
【问题讨论】:
-
嗯,我已经回答过了,但我不应该鼓励这个,所以还是有这个问题:你试过什么?
标签: php regex html-parsing