尝试捕获标记之间的所有文本。Php preg_match_all的行为不如预期
代码:
$test = '<test>foo<tests> asdlkfjklas lkflsdakj <test>sdfsd<tests> asdlkaskl <test>235234<tests>';
$match = '/<test>(.*)<tests>/';
preg_match_all($match, $test, $nextLink);
的print_r的结果:
Array ([0] => Array ([0] => foo asdlkfjklas lkflsdakj sdfsd asdlkaskl 235234) [1] => Array ([0] => foo asdlkfjklas lkflsdakj sdfsd asdlkaskl 235234))
使用非贪婪定量'' – Barmar
不结果包括所有的'',一切之间''在(*?)? –
Barmar
使用查看源查看它实际返回的内容,因为浏览器隐藏了看起来像HTML标记的内容。 – Barmar