getMatches(); // Check IPv4 address validity if (!empty($matches[4])) { $parts = explode('.', $matches[4]); foreach ($parts as $part) { if ($part > 255) { return false; } } } return true; } // // Public static methods // /** * Return the regex for an URI check. This can be called * statically. * @param $allowedSchemes Array of strings to restrict accepted schemes to defined set, or null for any * @return string */ static function getRegexp($allowedSchemes = null) { if (is_array($allowedSchemes)) { $schemesRegEx = '(?:(' . implode('|', $allowedSchemes) . '):)'; $regEx = $schemesRegEx . substr(PCRE_URI, 24); } else { $regEx = PCRE_URI; } return '&^' . $regEx . '$&i'; } } ?>