protected function toRegex($str)
    {
        $value = Expression::create($str);

        if ($value->isGlob()) {
            $value = $value->getRegex();

            if (false === strpos($str, '/')) {
                $value->setStartFlag(false);
            }
        }

        return $value->render();
    }