add capture name to returned matches

These compares are a little strange. Would it not be clearer to reverse them?
```
if (static_cast<int>(group_names_.size()) <= index)
```
Just a suggestion.