You are viewing a single comment's thread. Return to all comments →
for Python 3:
import re N= int(input()) for i in range(N): s = input() try: regex = re.findall(r"^([\da-f]{,4}\:){7}[\da-f]{,4}$", s) if regex: print("IPv6") else: regex = re.findall(r"^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$", s) if regex: print("IPv4") else: print("Neither") except Exception as e: pass
Seems like cookies are disabled on this browser, please enable them to open this website
IP Address Validation
You are viewing a single comment's thread. Return to all comments →
for Python 3: