Coming from another answer, I am stuck with a regexp (what are the odds...?).
$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);
Returns ( see example )
Array
(
)
Expected result
Array
(
[0] => Acme\MyBundle\Controller\MyController::myAction
[1] => Acme
[2] => My
[3] => My
[4] => my
)
Anyone can help? This regexp seems to be legit, maybe it's just a problem with the backslashes? I tried around but didn't get it.
Please try below expression. Is it expected? Or tell me your exact requirements.
<?php
$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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.