private function appendPattern(string $pattern, string $segment, int $start, int $length): string
    {
        if ($length < 1) {
            return $pattern;
        }

        $constant = substr($segment, $start, $length);
        $this->format .= $this->formatEncode($constant);
        return $pattern . preg_quote($constant, '/');
    }