title: Redshift regular expression for domain extraction
body: <p>I'm trying to form a regular expression for <code>REGEXP_SUBSTR (Redshift)</code> which will extract the sub-domain &amp; domain part from any given URL. </p>
  
  <p>I tried many suggestions from stackoverflow: regular-expression-extract-subdomain-domain, getting-parts-of-a-url-regex, how-to-get-domain-name-from-url and etc. Some of them work on regex validator but don’t work on Redshift. </p>
  
  <p><em>A regular expression should handle URLs with and without http/https prefix.</em></p>
  
  <p><strong>Is there any other way of extracting sub-domain &amp; domain from any given URL using a regular expression?</strong></p>