Skip to content

Instantly share code, notes, and snippets.

@skurfuerst
Created November 5, 2010 10:11
Show Gist options
  • Save skurfuerst/663915 to your computer and use it in GitHub Desktop.
Save skurfuerst/663915 to your computer and use it in GitHub Desktop.
<?php
$controllerObjectName = 'F3\Foo\Bla\Controller\Abc\Xyz\QuuxController';
$controllerObjectName = 'F3\Foo\Service\Rest\V1\QuuxController';
$matches = array();
preg_match('/
^F3
\\\\(?P<packageKey>[^\\\\]+)
(
\\\\Controller
|
\\\\(?P<subpackageKey>.+)\\\\Controller
|
)
\\\\(?P<controllerName>[a-z0-9\\\\]+)Controller
$/ix', $controllerObjectName, $matches
);
var_dump($matches);
?>
@skurfuerst
Copy link
Author

modifications:

  • moved the \ before "Controller" into the submatch
  • added 0-9 to the ControllerName
  • added empty alternative as LAST altrnative (order is important here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment