Defining Slim 4 Routes with REGEX (FastRoute)

Interesting… in routes.php

$app->get('/admin/{DBtable:[0-9]+}', ViewTableAction::class);
$app->get('/admin/{DBtable:[a-z]+}', ViewTableAction::class)

These examples, simple pattern matching against digits or letters both route as expected for routes such as:

https://example.com/admin/1234 and https://example.com/admin/sometext and also reject routes as expected for:
https://example.com/admin/1234sometext and https://example.com/admin/1234sometext

$app->get('/admin/{DBtable:/test/}', ViewTableAction::class)
$app->get('/admin/{DBtable:^test$}', ViewTableAction::class)
$app->get('/admin/{DBtable:test}', ViewTableAction::class)
$app->get('/admin/{DBtable:test|testcase}', ViewTableAction::class)

These examples of basic patterns forl ‘test’ and/OR ‘testcase’ anywhere in the trail end gives the ‘must be one of options’ error.

FastRoute docs says:

Custom patterns for route placeholders cannot use capturing groups. For example {lang:(en|de)} is not a valid placeholder, because () is a capturing group. Instead you can use […] {lang:en|de}