Z
Z
Zubastik_12018-04-07 10:38:57
PHP
Zubastik_1, 2018-04-07 10:38:57

Why doesn't regex work in router?

Here is the router
$app->get('/{id:(9|11)}', 'HomeController:index');
Here is the error:

Regex "(9|11)" for parameter "id" contains a capturing group

How to register correctly so that the router accepts only two id - 9, 11?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2018-04-07
@Zubastik_1

Everything, of course, depends on the internals of this router, but this is how it will most likely work:(?:9|11)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question