Answers for "laravel route regular expression match part of string"

0

laravel route regular expression constraints

Route::get('user/{name}', function ($name) {
    //
})->where('name', '[A-Za-z]+');

Route::get('user/{id}', function ($id) {
    //
})->where('id', '[0-9]+');

Route::get('user/{id}/{name}', function ($id, $name) {
    //
})->where(['id' => '[0-9]+', 'name' => '[a-z]+']);
Posted by: Guest on July-24-2021
0

laravel route regex except

Router::get('pages/{page}', ...)->where('page', '^(?!about|contact)$');
Posted by: Guest on August-13-2020

Code answers related to "laravel route regular expression match part of string"

Browse Popular Code Answers by Language