【发布时间】:2014-04-04 04:11:35
【问题描述】:
来自另一个答案,我被一个正则表达式困住了(几率是多少......?)。
$matches = array();
// $controller = $this->getRequest()->attributes->get('_controller');
$controller = "Acme\MyBundle\Controller\MyController::myAction";
preg_match('/(.*)\\\Bundle\\\(.*)\\\Controller\\\(.*)Controller::(.*)Action/', $controller, $matches);
print_r($matches);
返回 (see example)
Array
(
)
预期结果
Array
(
[0] => Acme\MyBundle\Controller\MyController::myAction
[1] => Acme
[2] => My
[3] => My
[4] => my
)
有人可以帮忙吗?这个正则表达式似乎是合法的,也许它只是反斜杠的问题?我试过了,但没有得到它。
【问题讨论】:
-
你想匹配什么?
-
它与
\MyBundle\部分不匹配,因为您的正则表达式中只有\Bundle\。 -
@ShankarDamodaran 呃,是的,抱歉,忘了详细说明,会更新。