PHP: how to grab an URL out of a chunk of text

bit.lyPHPregexurl

Let's say I have a big RSS feed full of Twitter posts, and they are all plain text. Lots of the posts contain URLs, and I'd like those URLs to be turned into links.

So I've got a variable that is equal to:

Visualization of layoffs by industry, number and date. Looking forward to seeing similar for hiring trends. http://bit.ly/XBW4z

And I'd like it to turn into:

Visualization of layoffs by industry, number and date. Looking forward to seeing similar for hiring trends. http://bit.ly/XBW4z

How could I do that? I am useless when it comes to regex and its ilk, so help is much appreciated!

Best Answer

Even I want one... Check the first link in the search result.Its pretty old!

and BTW look at the RHS.. we have similar questions. Recognize URL in plain text regex for url and image within a text or html