Closed Benjamin-Loison closed 2 months ago
echo checkRegex('The provided API key has an IP address restriction\. The originating IP address of the call \([0-9a-f:]{4,39}\) violates this restriction\.', $message) ? 'true' : 'false';
Source: the Stack Overflow answer 3261606
works fine.
Still have the issue for an IPv4 instance.
<?php
function checkRegex($regex, $str)
{
return preg_match("/^$regex$/", $str) === 1;
}
$message = '92';
echo "$message\n";
$regex = '\d{2}';
echo "$regex\n";
echo checkRegex($regex, $message) ? 'true' : 'false';
echo "\n";
works but not:
https://www.php.net/manual/en/regexp.reference.repetition.php
Wikipedia: IPv6#Address representation (1245019371)
A shortest IPv6 seems to be:
0::0
.