When googling, I see lots of examples like this:
App.Router = Backbone.Router.extend({
routes: {
'': 'index',
'show/:id': 'show'
},
index: function(){
$(document.body).append("Index route has been called..");
},
show: function(id){
$(document.body).append("Show route with id: " id);
}
});
How would this implementation look like using regex?
I want something like:
App.Router = Backbone.Router.extend({
routes: {
'': 'index',
/show/(\d+:id)/: 'show'
/show/([A-Za-z]+:other)/: 'showSpecial'
},
where the first regex matches /show/[any number]
and passes that number in the id
parameter to the show
function.
and where the second regex matches /show/[any word]
and passes that word in the other
parameter to the showSpecial
function.