Python 验证IPv6地址

来源:互联网 发布:洗车用什么软件 编辑:程序博客网 时间:2024/06/05 16:52
1. Standard notationeg.1763:0:0:0:0:b03:1:af18 1.1 check whether the whole subject text is an IPv6 address using standard notation^(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}$1.2 Find an IPv6 address using standard notation within a larger collection of text(?<![:.\w])(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}(?![:.\w])2. Mixed notationeg.1763:0:0:0:0:b03:127.32.67.152.1 Check whether the whole subject text is an IPv6 address using mixed notation^(?:[a-fA-F0-9]{1,4}:){6}(?:(?: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])$2.2 Find IPv6 address using mixed notation within a larger collection of text(?<![:.\w])(?:[a-fA-F0-9]{1,4}:){6}(?:(?: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])(?![:.\w])3. Compressed notationeg.1762::B03:1:AF183.1 Check whether the whole subject text is an IPv6 address using standard or compressed notation(?x)\A(?:# Standard(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}# Compressed with at most 7colons|(?=(?:[a-fA-F0-9]{0,4}:){0,7}[a-fA-F0-9]{0,4}\Z) # and anchored# and at most 1 double colon(([0-9a-fA-F]{1,4}:){1,7}|:)((:[0-9a-fA-F]{1,4}){1,7}|:)# compressed with 8 colons|(?:[a-fA-F0-9]{1,4}:){7}:|:(:[a-fA-F0-9]{1,4]){7})\Z3.2 Find IPv6 address using standard or compressed notation(?x)(?<![:.\w])(?:# Standard(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}# Compressed with at most 7colons|(?=(?:[a-fA-F0-9]{0,4}:){0,7}[a-fA-F0-9]{0,4}\Z) # and anchored# and at most 1 double colon(([0-9a-fA-F]{1,4}:){1,7}|:)((:[0-9a-fA-F]{1,4}){1,7}|:)# compressed with 8 colons|(?:[a-fA-F0-9]{1,4}:){7}:|:(:[a-fA-F0-9]{1,4]){7})(?![:.\w])

0 0
原创粉丝点击