I'd like to validate an IPv6 address using an algorithm that emphasizes readability. The ideal solution combines a dead-simple regular expression with source-code.
Using https://blogs.msdn.microsoft.com/oldnewthing/20060522-08/?p=31113 as an example:
function isDottedIPv4(s)
{
var match = s.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
return match != null &&
match[1] <= 255 && match[2] <= 255 &&
match[3] <= 255 && match[4] <= 255;
}
Notice how Raymond moves the complexity from the regular expression into code. I'd like a solution that does the same for IPv6.