Php matches the src content of img tags, too much?

$res = preg_match_all("/src="(.+\.(png|jpg))"+?/", "<img src="/Public/attached/image/20170227/20170227143202_25223.jpg" alt="" /><img src="Public/attached/image/20170227/20170227143202_25223.jpg" alt="" />", $matchs);

this result will match all the way to the second .jpg. How can I write to match the results of two images instead of just one?

Feb.27,2021

you have made a regular mistake,'/ src= "(. +. (png | jpg))" +? / 'there is only the first one, that is, the outside capture group uses the non-greedy mode, and the'. + 'inside does not use the non-greedy mode, instead of using the non-greedy mode, change it to'. +?' That should do it. If you don't sleep at this point, there will be no one left. No, no, no.)

Menu