ZF2 路由正则表达式

ZF2 Routing regexp

我尝试在 zend framework 2 中验证路由。

示例:

我试过这段代码,但收到 404 错误:

'overview' => array(
    'type'    => 'segment',
    'options' => array(
    'route'    => '/foo/overview/:nr',
    'constraints' => array('nr' => '^[0-9]{1,4}-[0-9]{4}$',),
    'defaults' => array(
    'controller' => 'Foo\Controller\Foo',
    'action'     => 'overview',
                                    ),
                            ),
                    ),

谢谢

使用 [0-9]{1,4}-[0-9]{4} 作为约束值就足够了,因为开始的 ^ 和结束的 $ 是由框架自动添加的(检查 match Zend\Mvc\Router\Http\Segment class).

中的函数