You'll need to use a regular expression of some kind. It'll be a nasty headfuck, and I can't write it because I don't know regex well enough. Read up on them if no one here can do it for you, but what you'll need to match is:
if <img src="http://*.jpg|png|gif|bmp" - don't match this, cause it has the img tag in front
you'll need a rule that can pick out image-ending URI's that don't have <img src=" in front of them, and have it be able to grab them regardless of http:// or lack of, as well as www or other subdomains. Maybe something space-based, but it's gonna be tricky to write. If you can't find anything, maybe look through some source code on CMS/bb systems - phpBB does this automatically with URI's, I believe, so it should be simple enough to modify to fit your needs if you can find it. If/when you do, post it back here, if you could.
Good luck!