Trying to match string like this:
/2011/10/Lorem-ipsum-dolor-it-amet-consectetur-adipisicing
/2011/10/Lorem-ipsum-dolor-it-amet-consectetur-adipisicing/
and
/2011/10/4545
/2011/10/4545/
And get year, month and the third segment back. This is regex I've got:
%/(?P<year>\d{4})/(?P<month>\d{2})/((?P<id>\d{1,})|(?P<permalink>.{1,}))[/]{0,1}$%
I though resulting matches array will always contain 3 variables: year,month and id or permalink. But what happens - if permalink is matched - I also still get empty id variable in the resulting array anyway. Is there a way to rewrite a regex so resulting array will only contain year, month and id or permalink ?