# Pastebin oZHMtpsR if (regex.global) { let previousOutput; while ((matches = regex.exec(output))) { previousOutput = inputString; output = replaceMatch(matches, output, regex, replacement); if (previousOutput === output) { break; } } } else if ((matches = output.match(regex)) !== null) { output = replaceMatch(matches, output, regex, replacement); }