function recurRegex(re, substitution, depth) {
      if (depth === -1) return "";

      return re.replace(substitution, _ => {
        return recurRegex(re, substitution, depth - 1);
      });
    }
Allows recursive regex expressions to a given depth

ie: recurRegex("(abc~~~)", /~~~/g, 2) becomes:
(abc(abc(abc)))

@param {string} re
@param {RegExp} substitution (should be a g mode regex)
@param {number} depth
@returns {string}``