The part that's hard to see is that there must be exactly one double colon :: in the address ... unless there are exactly seven colons, in which case there must be no double colon. For example,

0001:0002:0003:0004:0005:0006:0007:0008

The other and more important thing - which I forgot altogether - is that addresses that are mapped from IPv4 to IPv6 can optionally be written with the last two groups of hex digits replaced by a dotted-decimal IPv4 address, as in these two:

::ffff:10.32.12.1
::10.32.12.1

which are equivalent to

::ffff:0a20:0c01
::0a20:0c01

I think the suggestion from an Anonymous Monk of "Work less, use Net::IPv6Addr" is really a much better idea.

Adding the code to parse mapped address would turn the code I suggested from a mess into an abomination... a useful one to be sure, but still very very abominable. As Otto von Bismark might say, "Some CPAN modules are like laws and sausages, it is better not to see them being made."


In reply to Re^3: Regex host portion of IPv6 address by quester
in thread Regex host portion of IPv6 address by ewhitt

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.