title: Python using Regex to split URL into multiple parts
body: <p>For the URL link below,</p>
  <p><a href="https://www.amazon.com/" rel="nofollow noreferrer">https://www.amazon.com/</a></p>
  <p><a href="https://amazon.com/" rel="nofollow noreferrer">https://amazon.com/</a></p>
  <p><strong>How do I split them into three parts where:</strong></p>
  <p>1st part: The scheme(&quot;https://&quot;)</p>
  <p>2nd part: The domain(www.amazon or amazon)</p>
  <p>3rd part: The top level domain (&quot;com&quot;,&quot;edu&quot;...)</p>
  <p><strong>What I want it to return:</strong></p>
  <p>('https://', 'www.amazon', 'com')</p>
  <p>or</p>
  <p>('https://', 'amazon', 'com')</p>
  <p><strong>My approach:</strong></p>
  <p>My idea is to use the pattern below, the first part (http[s]?://) is going to get the 1st part where the [s]? will also capture if there is no s such as &quot;http://&quot;</p>
  <pre><code>pattern = &quot;((http[s]?://)((.+).))&quot;
  </code></pre>
  <p>However, when I try to do the second part, I can't seem to get it to start searching after &quot;https://&quot; as it returns the following result with the code below:</p>
  <p>Code that I ran:</p>
  <pre><code>re.search(pattern,'http://www.ycombinator.com/').groups()
  </code></pre>
  <p>The result I get:</p>
  <pre><code>('http://www.ycombinator.com/','http://','www.ycombinator.com/','www.ycombinator.com')
  </code></pre>
  <p>I am kinda stuck now, can someone please help?</p>
  <p>Thanks!</p>