nikic / FastRoute

Fast request router for PHP
Other
5.12k stars 445 forks source link

Quantifier not supported? #227

Closed ve3 closed 3 years ago

ve3 commented 3 years ago

I have a route like this.

/* @var $Rc \FastRoute\RouteCollector */
$Rc->addRoute('GET', '/countries/{country:[a-z]{3}}/states', 'handler');

This regular expression work correctly on normal PHP code but not working with FastRoute.

[a-z]{3}

It will be matched any A-Z character 3 times. Example: http://localhost/app/countries/BEL/states (get Belgium states/regions).

ve3 commented 3 years ago

OK, It have to be upper case

$Rc->addRoute('GET', '/countries/{country:[A-Z]{3}}/states', 'handler');