Regex raises exception when named capture group does not exist