title: Regular expression for finding URL in Java String
body: <p>How do you modify the following regex:</p>
  
  <pre><code>String URLpattern   = "((https?|ftp|gopher|telnet|file|Unsure|http):((//)|(\\\\))+[\\w\\d:#@%/;$()~_?\\+-=\\\\\\.&amp;]*)"
  </code></pre>
  
  <p>with one that takes into account ALL the following URL forms?</p>
  
  <pre><code>http://www.website.com
  https://www.website.com
  www.website.com
  website.com
  http://website.com
  https://website.com
  </code></pre>
  
  <hr>
  
  <p>EDIT:
  There are a bunch of already proposed solutions to the problem. I can list some of them:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/163360/regular-expresion-to-match-urls-in-java">Regular expression to match URLs in Java</a></li>
  <li><a href="https://stackoverflow.com/questions/14017154/regex-to-matches-a-url-with-or-without-http-in-java">Regex to matches a url with or without http in java</a> (nice since explained, however not working in my code)</li>
  <li><a href="https://stackoverflow.com/questions/13704362/regular-expression-match-url-without-http-and-any-other">Regular Expression, match url without &quot;http://&quot; and any other &quot;/&quot;</a></li>
  </ul>
  
  <p>However, although I tried all of them too, none of them is proposing an explanation of how and why the expression works. Thus, whenever there is a malfunctioning (and to me, a malfunctioning was happening in urls in the form <code>website.com</code> and <code>http://website.com</code>), it becomes difficult for newbies (like me ;) ) to apply any modification or understand what is going on when there is a failure.
  A well explained solution is always better than a solution made by others and not replicable in the next time =)</p>