I am trying to match url but can't figure out where I am wrong. I want to match urls like: /{type}/{location}.{upper-case-iso-code}/name.
Example: /hotel/paris.FR/belevue
I tried using following expressions:
(.*\.])[A-Z]{2}
and
([]{1,}\.])[A-Z]{2}
Here is my route:
Route::get('/hotel/{city_hotel_link}/{hotel}', 'HomeController@hotel')->where...;
^[a-z]+\/[a-z]+\.[A-Z]+\/[a-z]+$
It matches
hotel/paris.FR/belevue
If the ISO code only has 2 characters:
^[a-z]+\/[a-z]+\.[A-Z]{2}\/[a-z]+$
Regex for city_hotel_link part only
[a-z]+\.[A-Z]{2}\/?
you can use this regex to separate location, dot, and city code:
(.*).([A-Z]{2})
so the first group will be location and the second will be city code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.