public static function is_domain_matching_pattern($pattern) {
        if (!is_string($pattern)) {
            return false;
        }
        // Usually the trailing dot (null label) is omitted, but is valid if supplied. We'll just remove it and validate as normal.
        $pattern = rtrim($pattern, '.');

        // The entire name cannot exceed 253 ascii characters (255 octets, less the leading label-length byte and null label byte).
        if (strlen($pattern) > 253) {
            return false;
        }
        // A valid pattern must left-positioned wildcard symbol (*).
        // Tertiary domain labels can have 63 octets max, and must not have begin or end with a hyphen.
        // The TLD label cannot begin with a number, but otherwise, is only loosely restricted here (TLD list is not checked).
        $wildcard = '((\*)\.){1}';
        $domaintertiary = '([a-zA-Z0-9](([a-zA-Z0-9-]{0,61})[a-zA-Z0-9])?\.)*';
        $domaintoplevel = '([a-zA-Z](([a-zA-Z0-9-]*)[a-zA-Z0-9])?)';
        $address = '(' . $wildcard . $domaintertiary .  $domaintoplevel . ')';
        $regexp = '#^' . $address . '$#i'; // Case insensitive matching.
        return preg_match($regexp, $pattern, $match) == true; // False for error, 0 for no match - we treat the same.
    }