Limiting routing parameters for alphabets only in Laravel

We may use Regular Expression [[A-Za-z]+]+ to accept and parse out routing URL for alphabets only.


 | Application Routes
 | Here is where you can register all of the routes for an application.
 | It's a breeze. Simply tell Laravel the URIs it should respond to
 | and give it the controller to call when that URI is requested.

// will return 'Hello project root' on browser request /laravel/public
Route::get('/', function()
	return "Hello project root";

Route::get('person/{id}', function($id)
	return "Person : " . $id; 
->where('id', '[A-Za-z]+'); // using regular expression


URL : laravel/public/person/aaaBB
Output : Person : aaaBB


You may also like...