code: function extractRegExp(doc, expr, opts) {
    let group = opts.group;
    let flags = opts.flags;
    let str;
    if (typeof doc === 'string') {
      str = doc;
    } else {
      str = JSON.stringify(doc); // FIXME: not the same string as the one we got from the server
    }
    let rx;
    if (flags) {
        rx = new RegExp(expr, flags);
    } else {
        rx = new RegExp(expr);
    }
    let match = rx.exec(str);
    if (!match) {
      return '';
    }
    if(group && match[group]) {
      return match[group];
    } else if (match[0]) {
      return match[0];
    } else {
      return '';
    }
  }
docs: doc is a string or an object (body parsed by Request when headers indicate JSON)