title: PHP regex for validating a URL
body: <p>I'm looking for a decent regex to match a URL (a full URL with scheme, domain, path etc.)
  I would normally use filter_var but I can't in this case as I have to support PHP&lt;5.2!</p>
  
  <p>I've searched the web but can't find anything that I'm confident will be fool-proof, and all I can find on SO is people saying to use filter_var.</p>
  
  <p>Does anybody have a regex that they use for this?</p>
  
  <p>My code (just so you can see what I'm trying to achieve):</p>
  
  <pre><code>function validate_url($url){
      if (function_exists('filter_var')){
          return filter_var($url, FILTER_VALIDATE_URL);
          }
      return preg_match(REGEX_HERE, $url);
      }
  </code></pre>