< Home
regex matching image url with spaces

I need to match a image url like this:

http://site.com/site.com/files/images/img (5).jpg

Something like this works fine:

.replace(/(http:\/\/([ \S]+\.(jpg|png|gif)))/ig, "<div style=\"background: url($1)\"></div>")

Except if I have something like this:

http://site.com/site.com/files/audio/audiofile.mp3 http://site.com/site.com/files/images/img (5).jpg

How do I match only the image?

Thanks!

Edit: And I'm using javascript.

by Mark
on 6/30/2009 11:57:34 PM

Stackoverflow.mobi is not affiliated with stackoverflow.com but uses their public data dump to provide mobile access to stackoverflow.com's data