import socket
import sys
import re

def get_tld_server(tld="com"):
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect(("whois.iana.org", 43))
    sock.send("{}\n".format(tld).encode("utf-8"))
    for line in sock.makefile():
        tld_match = re.match("^(.*?): {1,}(.*?)$", line)
        if tld_match:
            if tld_match.group(1) == "whois":
                return tld_match.group(2)
        #print(repr(line))

def get_whois_data(domain, server=None):
    if not server:
        tld = domain.split(".")[-1]
        server = get_tld_server(tld)

    nextserver = None

    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect((server, 43))
    sock.send("{}\n".format(domain).encode("utf-8"))
    for line in sock.makefile():
        parts = re.match("^(.*?): {1,}(.*?)$", line.strip())
        if parts:
            if parts.group(1).lower() == "whois server":
                nextserver = parts.group(2)
        yield line.replace("\n", "")
    
    if nextserver:
        for line in get_whois_data(domain, nextserver):
            yield line

def main():
    if len(sys.argv) < 2:
        print("Usage: {} domain.com".format(sys.argv[0]))
        exit(1)

    for domain in sys.argv[1:]:
        for line in get_whois_data(domain):
            print(line)

if __name__ == "__main__":
    main()

@@ -1,16 +1,39 @@
+#!/usr/bin/env python3%0A
 import socket%0Aim
@@ -44,18 +44,8 @@
  sys
-%0Aimport re
 %0A%0Ade
@@ -102,42 +102,8 @@
 ket(
-socket.AF_INET, socket.SOCK_STREAM
 )%0A  
@@ -236,193 +236,231 @@
     
-tld_match = re.match(%22%5E(.*?): %7B1,%7D(.*?)$%22, line)%0A        if tld_match:%0A            if tld_match.group(1) == %22whois%22:%0A                return tld_match.group(2)%0A        #print(repr(line))
+parts = line.split(%22:%22, 2)%0A        if len(parts) %3E 1:%0A            header_name = parts%5B0%5D.strip()%0A            header_value = parts%5B1%5D.strip()%0A            if header_name.lower() == %22whois%22:%0A                return header_value
 %0A%0Ade
@@ -643,42 +643,8 @@
 ket(
-socket.AF_INET, socket.SOCK_STREAM
 )%0A  
@@ -778,51 +778,96 @@
 s = 
-re.match(%22%5E(.*?): %7B1,%7D(.*?)$%22, line
+line.split(%22:%22, 2)%0A        if len(parts) %3E 1:%0A            header_name = parts%5B0%5D
 .strip()
 )%0A  
@@ -862,26 +862,27 @@
 .strip()
-)
 %0A
+  
         
 if parts
@@ -877,17 +877,41 @@
     
-if parts:
+  header_value = parts%5B1%5D.strip()
 %0A   
@@ -926,22 +926,19 @@
  if 
-parts.group(1)
+header_name
 .low
@@ -994,22 +994,20 @@
 r = 
-parts.group(2)
+header_value
 %0A   

Use split instead of regular expression