Raphael Gbologah Raphael Gbologah - 2 months ago 5x
PHP Question

Php Regular Expression Complex Matching

I'm working on a php mvc routing system and i need my router to be able to get the various parts of the url and map it accordingly like in this example:

url = controller/method/parameters/another/something/page/7

should map to:

controller = controller, method = method, parameters = parameters/another/something, page = 7

currently am only able to match


with this regex:


which translates into this pattern:


I am using named captures to get the parts. i need help with the regex to use to get the result as stated above.


You need to allow /s in your parameter's character class.


Demo: https://regex101.com/r/nX7cZ8/1