original_string: 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.
      }
code: 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.
      }
code_tokens: 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. }
docstring: Checks whether the input string is a valid wildcard domain matching pattern.
  
  A domain matching pattern is essentially a domain name with a single, leading wildcard (*) label, and at least one other
  label. The wildcard label is considered to match at least one label at or above (to the left of) its position in the string,
  but will not match the trailing domain (everything to its right).
  
  The string must be dot-separated, and the whole pattern must follow the domain name syntax rules defined in RFC1034/1035.
  Namely, the character type (ascii), total-length (253) and label-length (63) restrictions. This function only confirms
  syntactic correctness. It does not check for the existence of the domain/subdomains.
  
  For example, the string '*.example.com' is a pattern deemed to match any direct subdomain of
  example.com (such as test.example.com), any higher level subdomains (e.g. another.test.example.com) but will not match
  the 'example.com' domain itself.
  
  @param string $pattern the string to check.
  @return bool true if the input string is a valid domain wildcard matching pattern, false otherwise.
docstring_tokens: Checks whether the input string is a valid wildcard domain matching pattern .