Possible Duplicate:
What is the PHP regex to convert text containing a URL into a hyperlink?
How can I turn a string like this:
My Name, http://www.mysite.com
into
<a href="http://www.mysite.com">My Name</a>
using regex?
Basically I want to autodetect if a URL is present in the string, and turn it into a link if it is. And if a name is not present then turn the link into something like
<a href="http://www.mysite.com">mysite.com</a>