栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

IPv6验证

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

IPv6验证

查看是否可行:

try {    if (subjectString.matches(        "(?ix)\A(?:      # Anchor addressn" +        " (?:  # Mixedn" +        "  (?:[A-F0-9]{1,4}:){6}          # Non-compressedn" +        " |(?=(?:[A-F0-9]{0,4}:){2,6}     # Compressed with 2 to 6 colonsn" +        "     (?:[0-9]{1,3}\.){3}[0-9]{1,3}          #    and 4 bytesn" +        "     \z)   #    and anchoredn" +        "  (([0-9A-F]{1,4}:){1,5}|:)((:[0-9A-F]{1,4}){1,5}:|:)  #    and at most 1 double colonn" +        " |::(?:[A-F0-9]{1,4}:){5}        # Compressed with 7 colons and 5 numbersn" +        " )n" +        " (?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}  # 255.255.255.n" +        " (?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])# 255n" +        "|     # Standardn" +        " (?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}         # Standardn" +        "|     # Compressedn" +        " (?=(?:[A-F0-9]{0,4}:){0,7}[A-F0-9]{0,4}    # Compressed with at most 7 colonsn" +        "    \z)    #    and anchoredn" +        " (([0-9A-F]{1,4}:){1,7}|:)((:[0-9A-F]{1,4}){1,7}|:)    #    and at most 1 double colonn" +        "|(?:[A-F0-9]{1,4}:){7}:|:(:[A-F0-9]{1,4}){7}# Compressed with 8 colonsn" +        ")/[A-F0-9]{0,4}\z        # Anchor address"))         {        // String matched entirely    } else {        // Match attempt failed    } } catch (PatternSyntaxException ex) {    // Syntax error in the regular expression}

大约一年前,我购买了一个非常有用的程序RegexMagic,用于计划使用的一些复杂正则表达式。

假定它是Java,所以应该编译,我假设/ 60可以在0000和FFFF的范围之间,您可以修改最后一部分。

/ [A-F0-9] {0,4}是我添加到正则表达式中以匹配您的示例的内容。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/410423.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号