[Edited - Sorry Bart] I\'ve looked at other answers but struggling to match this. I want to wrap an image tag where the src is the second attribute (after title) with a specific
Try this code:
';
preg_match('#src="(?:.*/)?(.*?)"#', $str, $match);
$src = $match[1];
?>
” />
EDIT: another version to account for multiple tags in the string:
$replace = '';
$str = preg_replace('#<\s*img.*?src="(?:[^"]+/)?(.*?)".*?>#s', $replace, $str);