title: Linkify Regex Function PHP Daring Fireball Method
body: <p>So, I know there are a ton of related questions on SO, but none of them are quite what I'm looking for. I'm trying to implement a PHP function that will convert text URLs from a user-generated post into links. I'm using the 'improved' Regex from Daring Fireball towards the bottom of the page: <a href="http://daringfireball.net/2010/07/improved_regex_for_matching_urls" rel="nofollow">http://daringfireball.net/2010/07/improved_regex_for_matching_urls</a>
  The function does not return anything, and I'm not sure why.</p>
  
  <pre><code>&lt;?php
  if ( false === function_exists('linkify') ):   
    function linkify($str) {
  $pattern = '(?xi)\b((?: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;?«»“”‘’]))';     
  return preg_replace($pattern, "&lt;a href=\"\\0\" rel=\"nofollow\" target=\"_blank\"&gt;\\0&lt;/a&gt;", $str);      
  }
  endif;
  ?&gt;
  </code></pre>
  
  <p>Can someone please help me get this to work?
  Thanks!</p>