ajbar7 Posted June 27, 2007 Share Posted June 27, 2007 Hi Guys, Im having an issue with the following regular expression trying to pull out the thing between the src="" in an image tag here is my code any help would be hugely appreciated cheers. My Code <? $img = "/ <img[ ]+[^>]*src[^>]*[^/].(?:jpg|bmp|gif)(?:\\\"|\') ^/"; echo $img; if (preg_match($img, "<img src='bob.jpg' />")) { echo "A match was found."; } else { echo "A match was not found."; } ?> Link to comment https://forums.phpfreaks.com/topic/57380-get-image-location-using-regular-epression/ Share on other sites More sharing options...
effigy Posted June 27, 2007 Share Posted June 27, 2007 $img = '/<img[^>]+src=(["\'])[^"\']+?\.(?:jpg|bmp|gif)\1/'; Link to comment https://forums.phpfreaks.com/topic/57380-get-image-location-using-regular-epression/#findComment-284014 Share on other sites More sharing options...
ajbar7 Posted June 27, 2007 Author Share Posted June 27, 2007 Thank-you!! Link to comment https://forums.phpfreaks.com/topic/57380-get-image-location-using-regular-epression/#findComment-284410 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.