java - IPv6 validation -


i used ipaddressutil.isipv6literaladdress (ipaddress) method validate ipv6, method fails ipv6-address/prefix-length format (format mentioned in rfc 4291 section 2.3) of ipv6.

could know validators validate " ipv6-address/prefix-length " format?

legal representations of ipv6

  1. abcd:ef01:2345:6789:abcd:ef01:2345:6789
  2. 2001:db8:0:0:8:800:200c:417a
  3. ff01:0:0:0:0:0:0:101
  4. 0:0:0:0:0:0:0:1
  5. 0:0:0:0:0:0:0:0
  6. 2001:db8::8:800:200c:417a
  7. ff01::101
  8. ::1
  9. ::
  10. 0:0:0:0:0:0:13.1.68.3
  11. 0:0:0:0:0:ffff:129.144.52.38
  12. ::13.1.68.3
  13. ffff:129.144.52.38
  14. 2001:0db8:0000:cd30:0000:0000:0000:0000/60
  15. 2001:0db8::cd30:0:0:0:0/60
  16. 2001:0db8:0:cd30::/60

not legal representations of ipv6

  1. 2001:0db8:0:cd3/60
  2. 2001:0db8::cd30/60
  3. 2001:0db8::cd3/60

see if works:

try {     if (subjectstring.matches(         "(?ix)\\a(?:                                                  # anchor address\n" +         " (?:  # mixed\n" +         "  (?:[a-f0-9]{1,4}:){6}                                # non-compressed\n" +         " |(?=(?:[a-f0-9]{0,4}:){2,6}                           # compressed 2 6 colons\n" +         "     (?:[0-9]{1,3}\\.){3}[0-9]{1,3}                     #    , 4 bytes\n" +         "     \\z)                                               #    , anchored\n" +         "  (([0-9a-f]{1,4}:){1,5}|:)((:[0-9a-f]{1,4}){1,5}:|:)  #    , @ 1 double colon\n" +         " |::(?:[a-f0-9]{1,4}:){5}                              # compressed 7 colons , 5 numbers\n" +         " )\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])           # 255\n" +         "|     # standard\n" +         " (?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}                    # standard\n" +         "|     # compressed\n" +         " (?=(?:[a-f0-9]{0,4}:){0,7}[a-f0-9]{0,4}               # compressed @ 7 colons\n" +         "    \\z)                                                #    , anchored\n" +         " (([0-9a-f]{1,4}:){1,7}|:)((:[0-9a-f]{1,4}){1,7}|:)    #    , @ 1 double colon\n" +         "|(?:[a-f0-9]{1,4}:){7}:|:(:[a-f0-9]{1,4}){7}           # compressed 8 colons\n" +         ")/[a-f0-9]{0,4}\\z                                                    # anchor address"))          {         // string matched entirely     } else {         // match attempt failed     }  } catch (patternsyntaxexception ex) {     // syntax error in regular expression } 

i purchased helpful program called regexmagic year ago complicated regular expressions planned on using.

this suppose java, should compile, assume /60 can between ranges of 0000 , ffff can modify last part.

/[a-f0-9]{0,4} added regular expression match example.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -