Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex Yii URL模式中的Yii合并和可选字符串_Regex_Yii_Yii Url Manager - Fatal编程技术网

Regex Yii URL模式中的Yii合并和可选字符串

Regex Yii URL模式中的Yii合并和可选字符串,regex,yii,yii-url-manager,Regex,Yii,Yii Url Manager,有没有办法整合以下Yii URL模式?例如,如何说零件是可选的 '<category:.+>-rezepte/mit-<ingredient:\w+>/<effort:\d+>/<difficulty:\w+>' => 'recipes/index', '<category:.+>-rezepte/mit-<ingredient:\w+>/<effort:\d+>'

有没有办法整合以下Yii URL模式?例如,如何说零件是可选的

  '<category:.+>-rezepte/mit-<ingredient:\w+>/<effort:\d+>/<difficulty:\w+>'    =>  'recipes/index',
  '<category:.+>-rezepte/mit-<ingredient:\w+>/<effort:\d+>'                     =>  'recipes/index',
  '<category:.+>-rezepte/mit-<ingredient:\w+>'                                  =>  'recipes/index',
  '<category:.+>-rezepte'                                                       =>  'recipes/index',


  'rezepte-mit-<ingredient:.+>/<category:\w+>/<effort:\d+>/<difficulty:\w+>'    =>  'recipes/index',
  'rezepte-mit-<ingredient:.+>/<category:\w+>/<effort:\d+>'                     =>  'recipes/index',
  'rezepte-mit-<ingredient:.+>/<category:\w+>'                                  =>  'recipes/index',
  'rezepte-mit-<ingredient:.+>'                                                 =>  'recipes/index',
'-rezepte/mit-/'=>“配方/索引”,
“-rezepte/mit-/”=>“配方/索引”,
“-rezepte/mit-'=>'配方/索引',
'-rezepte'=>“配方/索引”,
“rezepte mit-//”=>“配方/索引”,
“rezepte mit-/”=>“配方/索引”,
“rezepte mit-/”=>“配方/索引”,
“rezepte mit-”=>“配方/索引”,
根据需要,您应该能够执行以下操作:

array(
    'recipes/index',
    'pattern' => '<category:\w+>-rezepte(/mit-<ingredient:\w+>)?(/<effort:\d+>)?(/<difficulty:\w+>)?',
),
数组(
“配方/索引”,
'模式'=>'-rezepte(/mit-)?(/)?(/)?',
),

尝试将可选部分放在括号和问号之间,例如:()?如果我设置了()?我从Yii的createUrl()中获取了错误的url。比如:category1-rezepte/mit-ingre1/60(/all)?