For practice, I decided to build something like a Backbone router. The user only needs to give the regex string like r'^first/second/third/$' and then hook that to a View.

For Example, suppose I have a RegExp like this :

String regexString = r'/api/\w+/\d+/';
RegExp regExp = new RegExp(regexString);
View view = new View(); // a view class i made and suppose that this view is hooked to that url

And a HttRequest point to /api/topic/1/ and that would match that regex, then i can rendered anything hook to that url.

The problem is, from the regex above, how do i know that \w+ and \d+ value is topic and 1.

Care to give me some pointers anyone? Thank you.

Edit
Report