import re


def regex_replacement_stack(replacements):
    """
    Make a function that applies a sequence of regex replacements to text.
    """
    compiled_replacers = [(re.compile(match), replace) for (match, replace) in replacements]
    def _replace(text):
        for compiled_re, replacement in compiled_replacers:
            text = compiled_re.sub(replacement, text)
        return text
    return _replace