title: Using REGEXP_EXTRACT to get domain and subdomains
body: <p>I have only managed to extract the TLD of the list of websites that I have using</p>
  
  <pre><code>REGEXP_EXTRACT(Domain_name, r'(\.[^.:]*)]\.?:?[0-9]*$') AS web_tld
  </code></pre>
  
  <p>Example:</p>
  
  <p>I have </p>
  
  <pre><code>www.example1.abc.com
  www.example2.efg.123.net
  </code></pre>
  
  <p>I want the result</p>
  
  <p>Subdomain</p>
  
  <pre><code>example1
  efg
  </code></pre>
  
  <p>Domain</p>
  
  <pre><code>abc
  123
  </code></pre>
  
  <p>TLD</p>
  
  <pre><code>.com
  .net
  </code></pre>
  
  <p>EDIT:
  Encountered an error in my query
  'Exactly one capturing group must be specified'
  when I use (.?([^.:]+).([^.:]+).([^.:]+):?[0-9]*$) as regex</p>
  
  <pre><code>SELECT
  REGEXP_EXTRACT(Domain, r'(\.?([^.:]+)\.([^.:]+)\.([^.:]+):?[0-9]*$)'),
  FROM [weblist.domain]
  ORDER BY 1
  LIMIT 250;
  </code></pre>