Rather than re-regex here, I'd capture the group name in the first match.