문제

I want to make a regular expression for this laravel route.

Route::get('/{id}', 'HomeController@profile')

So far I was able to accept number only and string only using ->where('id', '\w+'); and )->where('id', '\d+');

But, I would like to make the rule so it accepts strings from 0-9, hyphen - and any string from A-Z or a-z

How can I do this. I haven't done any regex before.

도움이 되었습니까?

해결책

The regex you're looking for is: [0-9A-Za-z\-]+

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top