URL Reverse optional groups bug

Currently URL Reversing breaks when you you have an optional group with a named parameter. It looks like the reason being is in a pattern such as.
```
/app/(?P<website_id>\d)/articles/(?P<slug>([\w-]+/)?\d)/
```
When it's matching on the slug named group it captures the first closing paren next to the optional matcher `?` instead of the paren that actually closes the group.

I'm not sure that this can be solved with regular expressions as it involves balancing parentheses.