title: Regex to extract URL from text (with/without protocol and www or subdomains)
body: <p>I'm looking to extract the URL from a text inside an element. I'm not very good with regexp but this is what I have done so far:</p>
  
  <pre><code>var regexp = /((https?:\/\/)?[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?)/i;
  </code></pre>
  
  <p>Please check this fiddle to see how my regexp works: <a href="http://jsfiddle.net/h70mr1zt/5/" rel="nofollow">http://jsfiddle.net/h70mr1zt/5/</a></p>
  
  <p>This is the result that I need:</p>
  
  <pre><code> 1. stackoverflow =&gt; not found
   2. stackoverflow.com =&gt; found =&gt; stackoverflow.com
   3. www.stackoverflow.com =&gt; found =&gt; www.stackoverflow.com
   4. api.stackoverflow.com =&gt; found =&gt; api.stackoverflow.com
   5. http://www.stackoverflow.com =&gt; found =&gt; http://www.stackoverflow.com
   6. foo://www.stackoverflow.com =&gt; found =&gt; www.stackoverflow.com
   7. someone@stackoverflow.com =&gt; not found
   8. .com =&gt; not found
  </code></pre>
  
  <p>As you can see my fiddle I almost got everything right except for number <strong>7</strong> wherein it recognizes the domain part of the email address.</p>