private function createRegex($directiveUrlPath)
    {
        $hasMustEndWithWildcard = substr($directiveUrlPath, -1) === self::MUST_END_WITH_WILDCARD;
        if ($hasMustEndWithWildcard) {
            $directiveUrlPath = rtrim($directiveUrlPath, self::MUST_END_WITH_WILDCARD);
        }

        $directiveUrlPath = rtrim($directiveUrlPath, self::ANY_CHARACTER_WILDCARD);
        $directiveValueParts = explode(self::ANY_CHARACTER_WILDCARD, $directiveUrlPath);

        array_walk($directiveValueParts, function (&$directiveValue) {
            $directiveValue = preg_quote($directiveValue, '/');
        });

        return '/^' . implode(".*", $directiveValueParts) . ($hasMustEndWithWildcard ? '$' : '') . '/';
    }