regex - How to make regular expression to filter out for specific words for url in php laravel 8?

one text

Solution:

Wouldn't you just make a controller class and point both routes to the same controller? That way they do the same and you don't have to mess with unreadable regex magic in your code.

So like:

Route::get('/cars/{page}', CarsAndPlacesController::class);
Route::get('/places/{page}', CarsAndPlacesController::class);

With a controller like:

class CarsAndPlacesController extends Controller {
    public function __invoke(string $page) {
        // Do stuff
    }
}

Source