title: preg_replace issues with hyperlinks
body: <p>before I decided to post my first question on StackOverflow I turned completely crazy, so here it goes:</p>
  
  <p>I've got a website that uses Google Calendar API to fetch event entries. In the description section users can fill in some details about the event. Now i'd like them to be able to put in hyperlinks. This can happen in a couple of ways.
  User types:</p>
  
  <ul>
  <li><code>www.test.com</code></li>
  <li><code>http(s)://test.com</code></li>
  <li><code>http(s)://www.test.com</code></li>
  <li><code>&lt;a href="[one of above]" target="_blank"&gt;test.com&lt;/a&gt;</code></li>
  </ul>
  
  <p>What I'm desperately looking for is a way to convert them all to the format <code>&lt;a href="[http:// OR https:// OR www.]test.com" target="_blank"&gt;test.com&lt;/a&gt;</code></p>
  
  <p>I have already tried this syntax:</p>
  
  <pre><code>$pattern = "/(?i)\b((!&lt;?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()&lt;&gt;]+|\(([^\s()&lt;&gt;]+|(\([^\s()&lt;&gt;]+\)))*\))+(?:\(([^\s()&lt;&gt;]+|(\([^\s()&lt;&gt;]+\)))*\)|[^\s`!()\[\]{};:'\".,&lt;&gt;?«»“”‘’]))/";
  $description = preg_replace($pattern, "&lt;a href='http://$1'&gt;$1&lt;/a&gt;", $description);
  </code></pre>
  
  <p>It <strong>does</strong> change all events in the format www.test.com in a correct hyperlink, it <strong>does not</strong> change events in the format http(s)://www.test.com and http(s)://test.com. Input in the format <code>&lt;a href="[one of above]" target="_blank"&gt;test.com&lt;/a&gt;</code> becomes a mess.</p>
  
  <p>Now I'm sad and tired. If someone could help me out, you're an absolute genius!</p>