Match DN to pattern and extract the last capture group.

Updates offset to fully matched pattern.

@param string $pattern
@param int $offset
@return string|null Null if pattern doesn't match
545412
private function _regexMatch(string $pattern, int &$offset)
    {
        $idx = $offset;
        if (!preg_match($pattern, substr($this->_dn, $idx), $match)) {
            return null;
        }
        $idx += strlen($match[0]);
        $offset = $idx;
        return end($match);
    }
585945
public function offsetGet($offset)
    {
        $index = $this->findLine($offset);

        if ($index > 0) {
            $parsedKey   = null;
            $parsedValue = null;

            $parseOk = $this->parseEnvLine($this->lines[$index], $parsedKey, $parsedValue);

            return $parseOk ? $parsedValue : null;
        }

        return null;
    }
490085
public function match($pattern, array $patterns = []) {
        return $this->matcher->match(
            $this->addLeadingSlash($pattern), $this->getPath(), $patterns
        );
    }
825024
public function match(string $subject, $flags = 0, $offset = 0): int
	{
		$this->clean();
		return preg_match($this->pattern, $subject, $this->last_match, $flags, $offset);
	}
901083
public function isPatternMatches($pattern, $routePattern = false)
    {
        $uri = $this->removeIndexDotPhpAndTrillingSlash($this->getCurrentUri());
        $hasPattern = $this->hasNamedPattern($pattern);
        $pattern = ($hasPattern == false) ? $pattern : $hasPattern;
        if (preg_match_all(
            '#^' . $pattern . '$#',
            $uri,
            $matches,
            PREG_SET_ORDER
        )) {
            return $matches;
        }
    }
1088346
private static function toUnicodeRegex (& $pattern)
  {
    $d = $pattern[0];
    list ($exp, $flags) = explode ($d, substr ($pattern, 1), 2);
    $flags   = str_replace ('a', '', $flags, $isGlobal);
    $flags   = str_replace ('u', '', $flags) . 'u';
    $pattern = "$d$exp$d$flags";
    return $isGlobal;
  }
562256
public function regex($key, $pattern, $message = null)
    {
        if (is_array($key)) {
            foreach ($key as $k => $name) {
                $this->regex($name, is_array($pattern) ? $pattern[$k] : $pattern, $message);
            }
        } else {
            if (isset($this->scope[$key]) && ! (bool)preg_match($pattern, $this->scope[$key])) {
                $this->errors[$key] = sprintf($message !== null ? $message : self::$regexMessage, $key);
            }
        }

        return $this;
    }
739266
public static function match(Token $token, array $pattern)
    {
        // Token.
        if (isset($pattern['token'])
            && ($pattern['token'] !== $token->token)
        ) {
            return false;
        }

        // Value.
        if (isset($pattern['value'])
            && ($pattern['value'] !== $token->value)
        ) {
            return false;
        }

        if (isset($pattern['value_str'])
            && strcasecmp($pattern['value_str'], (string) $token->value)
        ) {
            return false;
        }

        // Type.
        if (isset($pattern['type'])
            && ($pattern['type'] !== $token->type)
        ) {
            return false;
        }

        // Flags.
        if (isset($pattern['flags'])
            && (($pattern['flags'] & $token->flags) === 0)
        ) {
            return false;
        }

        return true;
    }
200475
public function keys($pattern = null) {

        $keys = array();
        $stmt = $this->connection->query("SELECT `key` FROM ".$this->table." ORDER BY `key`;");
        $res  = $stmt->fetchAll(\PDO::FETCH_ASSOC);

        if (!$pattern) {

            foreach ($res as $record) {
                $keys[] = $record["key"];
            }

        } else {

            $matcher = function_exists('fnmatch') ? 'fnmatch': function($pattern, $string){
                return preg_match("#^".strtr(preg_quote($pattern, '#'), array('\*' => '.*', '\?' => '.'))."$#i", $string);
            };

            foreach ($res as $record) {
                if($matcher($pattern, $record["key"])) {
                    $keys[] = $record["key"];
                }
            }
        }

        return $keys;
    }
1229409
public function offsetGet($offset)
    {
        $hash = $this->hashAlgo->hash($offset);
        $filePath = $this->getCachePath() . $this->buildKeysCachingPath($hash) . $hash;

        return $this->offsetExists($offset) ? $this->codec->decode(file_get_contents($filePath)) : null;
    }
398372
public function offsetGet($offset)
    {
        return array_key_exists($offset, $this->filter) ? $this->filter[$offset] : null;
    }
1330809
public function lastIndexOf($string, $offset = null) {
		if (null === $offset) {
			$offset = $this->length();
		} else {
			$offset = $this->prepareOffset($offset);
		}

		if ($string === '') {
			return $offset;
		}

		/* Converts $offset to a negative offset as strrpos has a different
		 * behavior for positive offsets. */
		return mb_strrpos($this, (string) $string, $offset - $this->length(), $this->encoding);
	}
1128891
public function offsetGet($offset)
    {
        return isset($this->dates[$offset]) ? $this->dates[$offset] : null;
    }
776974
public function matches($pattern, $translation = null)
	{
		return $this->pattern === $pattern and (!$translation or $translation === $this->translation);
	}
771106
public function getMatches(
        string $regex,
        int $offset = 0,
        int $flags = self::PREG_NO_FLAGS
    ): MapInterface {
        return $this->capture($regex, $offset, $flags);
    }
128999
public function offsetGet($offset)
    {
        return isset($this->string[$offset]) ? $this->string[$offset] : null;
    }
1055744
public function match($pattern) {
        if (!$this->_isValid) {
            return $this;
        }
        if (!preg_match($pattern, $this->_unsafeVar)) {
            $this->_isValid = false;
        }
        return $this;
    }