public static function segmentIsOptional($segment)
        {
            $name = mb_substr($segment, 1);

            $optMarkerPos = mb_strpos($name, '?');

            if ($optMarkerPos === false) return false;

            $regexMarkerPos = mb_strpos($name, '|');

            if ($regexMarkerPos === false) return true;

            if ($optMarkerPos !== false && $regexMarkerPos !== false) return $optMarkerPos < $regexMarkerPos;

            return false;
        }