title: Regular expression Hostname
body: <p>I am developing a http robot, and I developed this regular expression
  <code>(((?:f|ht)tp(?:s)?\\://)?|www)([^/]+)</code> to detect and extract the hostname from a link (href).
  Now I put here the results of the tests:</p>
  
  <pre><code>String -&gt; http://www.meloteca.com/empresas-editoras.htm   
  Returns   http://www.meloteca.com
  </code></pre>
  
  
  
  <pre><code>String -&gt; www.meloteca.com/empresas-editoras.htm    
  Returns   www.meloteca.com
  </code></pre>
  
  
  
  <pre><code>String -&gt; /empresas-editoras.htm   
  Returns   empresas-editoras.htm (without the slash)
  </code></pre>
  
  <p>In this case I was expecting that the regular expressions did not return any value? Why is this happening?
  The same thing if I try with the following String </p>
  
  <pre><code>String -&gt; empresas-editoras.htm   
  Returns   empresas-editoras.htm
  </code></pre>
  
  <p>The snippet of code :</p>
  
  <pre><code>Pattern padrao = Pattern.compile("(((?:f|ht)tp(?:s)?\\://)?|www)([^/]+)");
          Matcher mat = padrao.matcher("empresas-editoras.htm");
          if(mat.find())
              System.out.println("Host-&gt;"+mat.group());
  </code></pre>