Hello;
Assume that I have a url in the form:
"item/a=5/b=5" and I am using a regular expression to capture the numbers in it with two groups of ([0-9]+). Now what I want to be able to do is reverse engineer this regexp for lets say 6 and 7 and get the url "item/a=6/b=7" back.
I know this can be done manually with string operations but I wanted to learn if it can be done using the regex itself.
The reason I want to do this is; I am trying to write my own url routing method. Lets say I map /products/3 to a controller ProductsController, action listAction add a parameter id = 3. I want to be able to create valid urls using a utility function createUrl($controller, $action, $params) by reverse engineering the regexp and replacing the groups with their new values.
Thanks.
Reverse engineering regular expressions
Moderator: General Moderators