Say I have a string, such as:
var map = "/directory/:id/thumbnails/:size";
And I want to use that to map against another string (essentially, the same thing that Rails uses to define Routes), such as:
var str = "/directory/10/thumbnails/large";
I would like to "compare" the two strings, and return a Key-Value Pair or JSON Object that represents the parts of str that map to map, which in my example above, would look like:
obj = {
'id' : '10',
'size' : 'large'
}
Would this be a good fit for JavaScript Regex? Can anyone help me?