import re


def _clean_on_regex(text, compiled_regex, activated=True):
    """Remove expressions corresponding to the given regex in a text"""
    if activated:
        text = re.sub(compiled_regex, "", text)
    return text