This matches a string ending with a known image extension.
<?php
$string = "Oddly enough I haven't found anywhere that has answer this question specificly, all the other stack overflow things I've found aren't exactly right.
I have a body text I need to search through for image urls, this doesn't mean anything complex but basically things like:
http://www.google.com/logo.png
http://reddit.com/idfaiodf/test.jpg
NOT
http://reddit.com/sadfasdf/test.jpgMORECONTENTHERE
";
$pattern = '~(http.*\.)(jpe?g|png|[tg]iff?|svg)~i';
$m = preg_match_all($pattern,$string,$matches);
print_r($matches[0]);
?>
Output
Array
(
[0] => http://www.google.com/logo.png
[1] => http://reddit.com/idfaiodf/test.jpg
[2] => http://reddit.com/sadfasdf/test.jpg
)