sha*_*nth 2 php regex zend-framework
我正在实现Zend Regex Routing,我必须对url执行多次检查.例如,如果这是我的网址:
HTTP://localhost/application/public/index.php/module/controller/action
这是我的bootstrap文件中的正则表达式条件,当url不包含"login"时匹配:
$router->addRoute('ui', new Zend_Controller_Router_Route_Regex(
'^((?!login/).)*$',
array(
'module' => 'mod1',
'controller' => 'cont1',
'action' => 'action1'
),
array( )
));
Run Code Online (Sandbox Code Playgroud)
现在我也想识别模式:([^-]*)/([^-]*)/([^-]*)从知道模块,控制器和动作的URL,以便我可以路由到它.
如何实现?
我绝对不知道Zend,但是正则表达式:
^(?=(?:(?!login/).)*$).*?/([^-/]*)/([^-/]*)/([^-/]*)/?$
Run Code Online (Sandbox Code Playgroud)
火柴:
entire match: "http://localhost/application/public/index.php/module/controller/action", from 0 to 70
- group(1) = "module"
- group(2) = "controller"
- group(3) = "action"
Run Code Online (Sandbox Code Playgroud)
在输入上:
http://localhost/application/public/index.php/module/controller/action
Run Code Online (Sandbox Code Playgroud)
该部分(?=((?!login/).)*$)确保login/字符串中没有,并在input()结束之前([^-/]*)/([^-/]*)/([^-/]*)/?$抓取最后三个..../$
HTH