I have a function in which recognizes the url
<?php
function findReplaceURL($text){
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
if(preg_match($reg_exUrl, $text, $url)) {
return preg_replace($reg_exUrl, "<a href=".$url[0]."target='_blank'>".$url[0]."</a>", $text);
} else {
return $text;
}
}
?>
What I'm trying to do is to recognize, not only the url of a site but also the images that end in jpg, png and gif that come from a url. Try using this expression: "%(?<=src=\")([^\"])+(png|jpg|gif)%i"
, but I do not get results.