python正则表达式匹配时间和IP地址

t = '19:16:30'
mt = re.match(r'^(0[0-9]|1[0-9]|2[0-3]|[0-9]):(0[0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]|[0-9]):(0[0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]|[0-9])$', t)
print mt.groups()

ip = '255.105.25.55'
ipm = re.match(r'^([1-9]?d|1dd|2[0-4]d|25[0-5]).([1-9]?d|1dd|2[0-4]d|25[0-5]).([1-9]?d|1dd|2[0-4]d|25[0-5]).([1-9]?d|1dd|2[0-4]d|25[0-5])$',ip)
print ipm
原文地址:https://www.cnblogs.com/zhzhang/p/5808551.html