title: regex to find first directory in URL if domain not in net, com or org
body: <p>I am sttrugling in getting a regex to extract the domain extension of a URL <a href="https://sub.hello.nl/nl/shop" rel="nofollow noreferrer">https://sub.hello.nl/nl/shop</a> (in this case &quot;nl&quot;) or the first two char subdomain between dots in case the domain extension is &quot;com&quot;, &quot;net&quot; or &quot;org&quot; <a href="http://sub.ca.hello.com/en/shop" rel="nofollow noreferrer">http://sub.ca.hello.com/en/shop</a> (&quot;ca&quot; in this other case)</p>
  <p><a href="http://sub.hello.nl/nl/shop" rel="nofollow noreferrer">http://sub.hello.nl/nl/shop</a> -&gt; nl</p>
  <p><a href="http://sub.ca.hello.com/en/shop" rel="nofollow noreferrer">http://sub.ca.hello.com/en/shop</a> -&gt; ca</p>
  <p>I got this little so far:</p>
  <pre><code>.[a-zA-Z]{2}\/
  </code></pre>
  <p>Any ideas?</p>