function extract(text, startPattern, endPattern, replacements = []) {
  const startIndex = text.indexOf(startPattern);
  if (startIndex === -1) throw new Error(`could not find: ${startPattern}`);
  const endIndex = text.indexOf(endPattern, startIndex);
  if (endIndex === -1) throw new Error(`could not find: ${endPattern}`);

  const subText = text.substring(startIndex, endIndex + endPattern.length);
  return doReplacements(subText, replacements);
}
@param {string} text
@param {string} startPattern
@param {string} endPattern
@param {[string|RegExp, string][]} replacements