Possible Duplicate:
What is a good regular expression to match a URL?
I have a string sent from the server that looks like this:
"Hey, have a look at this picture here http://example.com/fantastic.jpg, isn't it nice?"
I would like a regex function which does something like this:
function returnUrl(text) {
regex here ...
return url;
}
I am really bad with regex, so I am coming here asking for help. Please have a look at the picture below to get the idea of what I mean:
This is stackOverflow automatically changing my inserted text in a clickable URL, I suppose it's jQuery / regex.
Thanks in advance.
EDIT:
Forgot to mention, this regex should only work for images (jpg, png, etc.) not for all links.