title: Clean and extract Subdomains & Domains from URLs using Regex Notepad++
body: <p>This is simple text file. </p>
  
  <p>The URL:</p>
  
  <ul>
  <li>Can have https:// or http://</li>
  <li>Eliminate both as well as trailing url/ file paths </li>
  <li>Extract only domains and/or subdomains </li>
  </ul>
  
  <p>I have Notepad++ and EditPlus</p>
  
  <p>open to other Suggestions? </p>
  
  <p>Examples: </p>
  
  <blockquote>
    <p><a href="https://appspace.com" rel="nofollow noreferrer">https://appspace.com</a></p>
    
    <p><a href="http://appspace.com/" rel="nofollow noreferrer">http://appspace.com/</a></p>
    
    <p><a href="http://ayurfit.ning.com/main/authorization/signIn" rel="nofollow noreferrer">http://ayurfit.ning.com/main/authorization/signIn</a></p>
    
    <p><a href="http://bangalore.olx.in/login.php" rel="nofollow noreferrer">http://bangalore.olx.in/login.php</a></p>
    
    <p><a href="http://birthdayshoes.com/forum/index.php" rel="nofollow noreferrer">http://birthdayshoes.com/forum/index.php</a></p>
    
    <p><a href="http://birthdayshoes.com/forum/register/" rel="nofollow noreferrer">http://birthdayshoes.com/forum/register/</a></p>
    
    <p><a href="http://forums.virtualbox.org/ucp.php" rel="nofollow noreferrer">http://forums.virtualbox.org/ucp.php</a></p>
  </blockquote>
  
  <p>Tries: </p>
  
  <pre><code>/(?!.{253})((?!-)[A-Za-z0-9-]{1,63}(?&lt;!-)\.){1,126}+[A-Za-z]{2,6}/ 
  ^(?:https?://)?([^/.]+(?=\.)|)(\.?[^/.]+\.[^/]+)/?(.+|)$
  </code></pre>
  
  <p><a href="https://regex101.com/r/hZ4cL4/4" rel="nofollow noreferrer">https://regex101.com/r/hZ4cL4/4</a></p>
  
  <p>Tried many on other machine as examples from Regex101</p>
  
  <p>Found this little nugget as well. I'll post how its different once I understand it. </p>
  
  <p><a href="https://stackoverflow.com/questions/25703360/regular-expression-extract-subdomain-domain?rq=1">Regular Expression - Extract subdomain &amp; domain</a></p>