I have a WordPress site, and am using AJAX to update the archive rather than page reloads (in very basic terms).
So I can either be passing:
http://mysite.com/events/2012/10/17
http://mysite.com/events/2012/10
http://mysite.com/events/2012
I am looking for a JS/jQuery regex method that will retrieve any of these. So far I have the following:
var linkUrl = 'http://mysite.com/events/2012/10';
var linkDate = linkUrl.match(/\d{4}(\/\d{2})+/);
console.log( linkDate ); // output - ["2012/10", "/10", index: 8, input: "/events/2012/10"]
It appears that it's finding 2 matches, the second of which is not what I want. I'm sure it's a simple thing in my regex.