in reply to Reg expression to replace URLs with Anchor tags in Tweets

Bloodnok's solution will work, but will break if someone will use 'HTTP' (all caps) or if the term 'http' is used on its own.

To make it a little bit safer, perhaps the following can be considered:

s{(https?://\S+)}{<a href="$1">$1</a>}i;
However, if you really want to make sure that it is a well-crafted URL, you should explore Regexp::Common.

As a penance for your sin of asking a PHP question in our Perl Monastery, you are advised to implement Regexp::Common in PHP so the poor misguided souls using PHP will see the Glory of Perl!

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James