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."; } ?> Quote 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/'; Quote 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!! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.