i have php class url rewriting. want route urls:
- services-paris/ - services-paris/8/ - services/
the formula is: services[ "-" + (city) ]? / [ (0-9) + "/" ]?
first thing [ "-" + (city) ]?
, means: optional + must start "-", return city.
second thing [ (0-9) + "/" ]?
, means: optional + numbers + end "/" return numbers.
the second thing pagination.
finally need these informations know city , page.
so.. pattern, newbie @ regex.
thanks!
you use regex :
services(?:-([^\/]+))?\/(?:(\d+)\/)?$
it's gonna give table of matches contains :
- the city name (wihtout '-')
- the number after first '/' , before second '/'
note city name mustn't contain '/' character.
Comments
Post a Comment