How do I make a URL text a link?
<p>Say on Facebook or Twitter, when I type "www.google.com" and submit it, it becomes a link. How do I code this in PHP? Do I use regular expressions to get where the www starts and the .com ends?</p>

<p>Is this how they do it?</p>

<pre><code>&lt;?PHP 
//some regular expression to get www and .com part
$link="&lt;a href='$url'&gt;$url&lt;/a&gt;";
echo $link;
?&gt;
</code></pre>

<p>How do I write a regular expression to get the "www" and ".com" part?</p>

<p>And for twitter's @obama, obama would become a link to obama's site.
What regular expression do they use to get the text after the @ and before the space?</p>
