3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = '%(?<attr>src|href)="(?<host>.*?)(?<media>/media/[^"]+)"%i'; $content = <<<CONTENT <p><img alt="" src="/media/images/logo_medias/TV/TF1.jpg" style="height:22px; width:60px" />&nbsp;&nbsp;<img alt="" src="/media/images/logo_medias/TV/W9.jpg" style="height:22px; width:60px" />&nbsp; <img alt="" src="/media/images/logo_medias/TV/Gulli.jpg" style="height:29px; width:30px" /><strong>&nbsp;</strong><img alt="" src="/media/images/logo_medias/TV/DISNEY%20CHANNEL.jpg" style="color:rgb(76, 76, 76); font-size:15.555556297302246px; height:40px; line-height:22.986112594604492px; width:44px" /><strong>&nbsp;<img alt="" src="/media/images/logo_medias/TV/NT1.jpg" style="height:29px; width:35px" /></strong>&nbsp;-&nbsp;Campagne de spots<br /> <img alt="" src="http://infoscom.umf.dev/media/images/Pluzz.jpg" style="height:219px; width:219px" /><a alt="" href="http://infoscom.umf.dev/media/images/Pluzz.jpg" style="height:219px; width:219px" /></p> CONTENT; $callback = function($match) { var_dump($match); return $match[0]; }; var_dump(preg_replace_callback($pattern, $callback, $content));

preferences:
39.18 ms | 402 KiB | 5 Q