title: Python truncates a valid regex pattern string
body: <p>Honestly, trying to find a solution to this problem has been driving me insane, because every answer is either about using regex to truncate a string, or regex patterns having a max length (in which case, shouldn't it throw an error, not truncate the pattern string?)</p>
  
  <p>Anyways. I'm using a regex pattern supplied by my employer. The intent is to match only the host name in any url string (so like python.org from <a href="https://docs.python.org/3/howto/regex.html" rel="nofollow noreferrer">https://docs.python.org/3/howto/regex.html</a>). I've seen recommendations to use urllib.parse, but it doesn't strip out the hostname properly if there is a subdomain. Here is the regex string I was given to use:</p>
  
  <pre><code>\b(([a-zA-Z0-9\-_]+)\.)+
  (?!exe|php|dll|doc|docx|txt|rtf|odt|xls|xlsx|ppt|pptx|bin|
  pcap|ioc|pdf|mdb|asp|html|xml|jpg|gif|png|lnk|log|vbs|lco|bat|shell|quit|pdb|vbp|
  bdoda|bsspx|save|cpl|wav|tmp|close|py|ico|ini|sleep|run|dat|scr|jar|jxr|apt|w32|css|
  js|xpi|class|apk|rar|zip|hlp|tmp|cpp|crl|cfg|cer|plg|tmp)([a-zA-Z]{2,5}|support|report|
  i2p|technology|xn--p1ai|com#|moscow|technology)
  </code></pre>
  
  <p>It's very long. If I place it into a regex checker such as <a href="https://pythex.org" rel="nofollow noreferrer">https://pythex.org</a>, it happily tells me that it works perfectly. However, if I use either a Python shell or the Python interpreter, compiling it and then returning the compiled pattern gives me this:</p>
  
  <pre><code>re.compile('\\b(([a-zA-Z0-9\\-_]+)\\.)+(?!exe|php|dll|doc|docx|txt|rtf|odt|xls|xlsx|
  ppt|pptx|bin|pcap|ioc|pdf|mdb|asp|html|xml|jpg|gif|png|lnk|log|vbs|lco|bat|shell|quit|
  pdb|vbp|bdoda|bsspx|save|cpl|wav|tmp|clos)
  </code></pre>
  
  <p>Can someone tell me why it's being truncated (for my own knowledge), and suggest a better way to do things? The goal is to do something like this:</p>
  
  <pre><code>https://docs.python.org/3/library/socket.html -&gt; python.org
  www.example.info                              -&gt; example.info
  docs.google.com                               -&gt; google.com
  </code></pre>