如何在两个标签之间匹配(PCRE)所有内容?
我试过这样的事情:
(.*)
但它对我来说效果不佳..
我对正则表达式有点新意,所以我希望有人能够向我解释如何实现这一点,如果它可以用正则表达式来实现的话.
谢谢
$string = 'text'; $regex = '#(.*?)#s'; preg_match($regex, $string, $matches); print_r($matches); // $matches[1] =text
解释:
(.*?) = non greedy match (match the first it finds s = modifier in $regex (end of the variable) allows multiline matches such as 'stuff more stuff '