Possible Duplicate:
PHP URL to Link with Regex
I am trying to preg_replace
all links in a textblock, so that they are replaced with the string "<< IMAGE >>"
I am trying to match all links in this text block:
"Here we can see the chupacabra trying to eat http://somesite.com/img/chupacabra.jpg.
look at the the snails somesite.com/img/snails.png"
I am using this regexp:
(https?:\/\/)?.*(jpg|png|jpeg|bmp|gif)
But I can't get it to select only the exact strings of links.
What I need is this:
"Here we can see the chupacabra trying to eat http://somesite.com/img/chupacabra.jpg
.
look at the the snails somesite.com/img/snails.png
"
Testing on regexpal.com