$matchesIP =
explode(':',
$IPv6);
$groupCount =
count($matchesIP);
$colons =
strpos($IPv6, '::'
);
if (count(preg_grep('/^[0-9A-Fa-f]{0,4}$/',
$matchesIP, PREG_GREP_INVERT
)) !== 0
) { $this->warnings
[IPV6BadChar::CODE
] =
new IPV6BadChar();
} if ($colons === false
) { // We need exactly the right number of groups
if ($groupCount !==
$maxGroups) { $this->warnings
[IPV6GroupCount::CODE
] =
new IPV6GroupCount();
} return;
} if ($colons !==
strrpos($IPv6, '::'
)) { $this->warnings
[IPV6DoubleColon::CODE
] =
new IPV6DoubleColon();
return;
} if ($colons === 0 ||
$colons === (strlen($IPv6) - 2
)) { // RFC 4291 allows :: at the start or end of an address