You are viewing a single comment's thread. Return to all comments →
import re pattern_ipv4 = r'^(\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])){3}$' pattern_ipv6 = r'^([\da-f]{,4})(:([\da-f]{,4})){7}$' for _ in range(int(input())): line = input() if re.match(pattern_ipv4, line): print('IPv4') elif re.match(pattern_ipv6, line): print('IPv6') else: print('Neither')
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 →