protected static function _tokenizeSegment($pattern, $delimiter, &$variable = null)
    {
        $tokens = [];
        $index = 0;
        $path = '';

        if (preg_match_all('~' . static::PLACEHOLDER_REGEX . '()~x', $pattern, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
            foreach ($matches as $match) {
                $offset = $match[0][1];

                $path .= substr($pattern, $index, $offset - $index);
                $index = $offset + strlen($match[0][0]);

                if ($path) {
                    $tokens[] = $path;
                    $path = '';
                }

                $variable = $match[1][0];
                $capture = $match[2][0] ?: '[^' . $delimiter . ']+';

                $tokens[] = [
                    'name'      => $variable,
                    'pattern'   => $capture
                ];
            }
        }

        if ($index < strlen($pattern)) {
            $path .= substr($pattern, $index);
            if ($path) {
                $tokens[] = $path;
            }
        }
        return $tokens;
    }