title: Getting parts of a URL (Regex)
body: <p>Given the URL (single line):<br>
  <a href="http://test.example.com/dir/subdir/file.html" rel="noreferrer">http://test.example.com/dir/subdir/file.html</a></p>
  
  <p>How can I extract the following parts using regular expressions:</p>
  
  <ol>
  <li>The Subdomain (test)</li>
  <li>The Domain (example.com)</li>
  <li>The path without the file (/dir/subdir/)</li>
  <li>The file (file.html)</li>
  <li>The path with the file (/dir/subdir/file.html)</li>
  <li>The URL without the path (<a href="http://test.example.com" rel="noreferrer">http://test.example.com</a>)</li>
  <li>(add any other that you think would be useful)</li>
  </ol>
  
  <p>The regex should work correctly even if I enter the following URL:  </p>
  
  <pre><code>http://example.example.com/example/example/example.html
  </code></pre>