function patchRegex(re, config) {
  if (!cachedRegexes.has(config)) {
    cachedRegexes.set(config, {});
  }
  const cache = cachedRegexes.get(config);
  if (re in cache) {
    return cache[re];
  }
  let patched = '\\!?';
  // Prefix
  if (config.prefix.length) {
    patched += escapeSpecialChars(config.prefix);
  }
  // Props
  let replaced = re;
  const propsRe = /\$\{(\-?[a-z]*)\}/gi;
  const res = replaced.matchAll(propsRe);
  const resArray = [...res];
  const props = resArray.map((arr) => arr[1]);
  if (props.length === 0) {
    return (cache[re] = `${patched}(${replaced})`);
  }
  // e.g. backgroundColor, letterSpacing, -margin...
  props.forEach((prop) => {
    const token = new RegExp('\\$\\{' + prop + '\\}');
    const isNegative = prop.substr(0, 1) === '-';
    const absoluteProp = isNegative ? prop.substr(1) : prop;
    if (prop === 'dark') {
      // Special case, not a default property from the theme
      replaced = replaced.replace(token, generateOptions(absoluteProp, [], config, isNegative));
      return `${patched}(${replaced})`;
    } else if (prop === 'arbitraryProperties') {
      // Special case
      replaced = replaced.replace(
        new RegExp('\\$\\{' + absoluteProp + '\\}'),
        generateOptions(absoluteProp, [], config, isNegative)
      );
      return `${patched}(${replaced})`;
    } else if (prop === 'backgroundImageUrl') {
      // Special case
      replaced = replaced.replace(new RegExp('\\$\\{' + prop + '\\}'), generateOptions(prop, [], config, false));
      return `${patched}(${replaced})`;
    } else if (!config.theme || !config.theme[absoluteProp]) {
      // prop not found in config
      return;
    }
    // Normal scenario
    const keys = Object.keys(config.theme[absoluteProp])
      .filter((key) => {
        if (isNegative) {
          // Negative prop cannot support NaN values and inherits positive values
          const val = config.theme[absoluteProp][key];
          const isCalc = typeof val === 'string' && val.indexOf('calc') === 0;
          const num = parseFloat(val);
          if (isCalc) {
            return true;
          }
          if (isNaN(num)) {
            return false;
          }
        } else if (key[0] === '-') {
          // Positive prop cannot use key starting with '-'
          return false;
        }
        return true;
      })
      .map((key) => {
        if (isNegative && key[0] === '-') {
          return key.substring(1);
        }
        return key;
      });
    if (keys.length === 0 || replaced.match(token) === null) {
      // empty array
      return;
    }
    const opts = generateOptions(absoluteProp, keys, config, isNegative);
    replaced = replaced.replace(token, opts);
  });
  return (cache[re] = `${patched}(${replaced})`);
}
Customize the regex based on config

@param {String} re Regular expression
@param {Object} config The merged Tailwind CSS config
@returns {String} Patched version with config values and additional parameters