replaceUsingRegExp = (macroText, macroRegExp, macroReplacer) => {
  macroRegExp.lastIndex = 0;
  let replaceMatch = macroRegExp.exec(macroText);
  let replaceResult;
  if (replaceMatch) {
    replaceResult = "";
    let replaceLastIndex = 0;
    do {
      if (replaceLastIndex !== replaceMatch.index) {
        replaceResult += macroText.substring(
          replaceLastIndex,
          replaceMatch.index,
        );
      }
      const replaceInput = replaceMatch[0];
      replaceResult += macroReplacer(replaceInput);
      replaceLastIndex = replaceMatch.index + replaceInput.length;
      // eslint-disable-next-line no-cond-assign
    } while ((replaceMatch = macroRegExp.exec(macroText)));

    if (replaceLastIndex !== macroText.length) {
      replaceResult += macroText.substring(replaceLastIndex);
    }
  } else {
    replaceResult = macroText;
  }
  return replaceResult;
}
@param {string} macroText
@param {RegExp} macroRegExp
@param {(input: string) => string} macroReplacer
@returns {string}