Php 拉威尔布线-破折号

Php 拉威尔布线-破折号,php,laravel,Php,Laravel,我需要创建一个在变量后带有破折号的路由。我想要的很容易用代码解释(这是我尝试过的,但它不起作用) 问题在于这部分“赔率”。当我加上,我得到了这个内容的Laravel错误 $others = $this->checkForAlternateVerbs($request); if (count($others) > 0) { return $this->getOtherMethodsRoute($request, $othe

我需要创建一个在变量后带有破折号的路由。我想要的很容易用代码解释(这是我尝试过的,但它不起作用)

问题在于这部分“赔率”。当我加上,我得到了这个内容的Laravel错误

$others = $this->checkForAlternateVerbs($request);

        if (count($others) > 0)
        {
            return $this->getOtherMethodsRoute($request, $others);
        }

        throw new NotFoundHttpException;

如何执行此操作(在管线中的参数后添加破折号)?谢谢

问题在于,如果在路由参数之后出现以下字符之一:
/,;:-_~+*=@|,您不能在该route参数内使用它,因为Laravel会调整正则表达式以排除该参数

我相信这样做的原因是这样一个场景:
test/{foo}-{bar}

这意味着您可以明显地将URL更改为不在route参数内使用
-
,或者使用
where()
指定应用于
tournamentName
的正则表达式条件:


您的代码运行良好。确切的错误是什么?错误截图,我试图访问的url是domain.com/tourbank/soccer/england/premier-league-odds@VladimirSabo-该URL中没有
赛马
。抱歉,复制错误,仍然不起作用,如果我将“-赔率”改为“\u赔率”,效果很好。我没有问题让同一条路线正常工作。您使用的是哪种Laravel版本?
$others = $this->checkForAlternateVerbs($request);

        if (count($others) > 0)
        {
            return $this->getOtherMethodsRoute($request, $others);
        }

        throw new NotFoundHttpException;
Route::any('tournament/{sportName}/{regionName}/{tournamentName}-odds',
         array('as' => 'tournament-page', 'uses' => 'HomeController@tournament')
     )->where('tournamentName', '[^\/]+');