I have a regex: ^(profile\/\~)(:\([0-9a-z,-]+\))?$
this allows strings like: profile/~
or profile/~:(var1,var2,var3,...)
I need to configure this regex into a Slim route for accept the following routes.
http://example.com/v1/profile/~:(var1, var2)
http://example.com/v1/profile/~:
My PHP code:
$app = new \Slim\App;
$app->group('/v1', function () {
$this->get('/profile/~[:[{fields:[0-9a-z,-]+}]]', function ($request, $response, $args) {
$name = $request->getAttribute('name');
$response->getBody()->write("Hello " . $args['fields']);
return $response;
})->setName('profile');
});
$app->run();
Is there any way to convert that regex to one compatible with slim?