python正则表达式问题,请帮助解释下面匹配的理由
str1='127.0.0.1192.168.1.66'match=re.findall(pattern,str1)print(match)当pattern=r'[1-9...
str1 = '127.0.0.1 192.168.1.66'
match = re.findall(pattern,str1)
print(match)
当pattern = r'[1-9]{1,3}(\.[0-9]{1,3})'
输出结果为['.0', '.168', '.66']
当pattern = r'(\.[0-9]{1,3})'
输出为['.0', '.0', '.1', '.168', '.1', '.66']
当pattern = r'[1-9]{1,3}(\.[0-9]{1,3}){3}'
输出为['.1', '.66'] 展开
match = re.findall(pattern,str1)
print(match)
当pattern = r'[1-9]{1,3}(\.[0-9]{1,3})'
输出结果为['.0', '.168', '.66']
当pattern = r'(\.[0-9]{1,3})'
输出为['.0', '.0', '.1', '.168', '.1', '.66']
当pattern = r'[1-9]{1,3}(\.[0-9]{1,3}){3}'
输出为['.1', '.66'] 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询