Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 4
    Although I admire your effort as well, I think there's a huge design flaw in your construct: It's way too big! I would never trust a regex of this size that was not used by thousands of people for years. Commented Apr 16, 2014 at 12:05
  • 1
    @erikb85: Take a look at the script I posted to Pastebin. It contains 1154 tests of different IPv6 formats, and it passes every single one of them. If you think more tests are necessary, feel free to modify my script, add tests, and post the results. Commented May 24, 2014 at 9:36
  • I found out that simply doing ipaddress.IPv6Address(my_addr) also matches every test case result you posted so if you have Python 3.3+ you can use that... note that the corresponding IPv4 function was not so great and failed a number of (different) test cases involving leading zeros... Commented Nov 29, 2022 at 18:16