for (let match of matches) {
    if (match.startsWith('[') && match.endsWith(']')) {
      match = match.replace(/^\[/, '').replace(/]$/, '');
    }
    result = result.replace(match, get(fields, match));