1 回答 1

3

.你的字符串中有一个额外的。

// This:
$pattern = '/<img(.*) src="([^"]*)"(.*)\>/i';

// Not this:
$pattern = '/<img(.*) src="([^"].*)"(.*)\>/i';

然而,与其做一个奇怪的替换来移除你不想要的部分,我会考虑拉出你想要的部分并打印它们。

$matches = array();
preg_match_all('/<img.*?src="([^"]*)"/i', $text, $matches);
echo implode("\n", $matches[1]);
于 2013-04-04T04:34:46.820 回答