I am looking for some help with regex.
I have this piece of code:
$router->add(
'/activate/{token:[a-zA-Z0-9]+}',
array (
'module' => 'frontend',
'controller' => 'user',
'action' => 'activate'
)
);
which works just fine. However the one below does not:
$router->add(
'/activate/{token:[a-zA-Z0-9]{32}}',
array (
'module' => 'frontend',
'controller' => 'user',
'action' => 'activate'
)
);
The matching mechanism that I have in C is (which works with preg_match_all also)
'#{([a-zA-Z][a-zA-Z0-9\_\-]*)(:([^}]+))*}#'
I would appreciate some pointers as to how to make the second example work.
EDIT
preg_match_all(
'#{([a-zA-Z][a-zA-Z0-9\_\-]*)(:([^}]+))*}#',
'/manual/{language:[a-z]{2}}/{file:[a-z]+}.html',
$matches,
PREG_SET_ORDER
);
I want it to return something like this:
Array
(
[0] => Array
(
[0] => {language:[a-z]{2}}
[1] => language
[2] => :[a-z]{2}
[3] => [a-z]{2}
)
[1] => Array
(
[0] => {file:[a-z]+}
[1] => file
[2] => :[a-z]+
[3] => [a-z]+
)
)
This regular expression: ‘#{([a-zA-Z0-9_-])(:(.)}?)}#’ works for both of them: