<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def replace_characters(self, text, characters, replacement=''):
 """Remove characters from text. Removes custom characters from input text or replaces them with a string if specified. Args: text: The text to be processed. characters: Characters that will be replaced. replacement: New text that will replace the custom characters. Returns: The text without the given characters. """

        if not characters:
            return text

        characters = ''.join(sorted(characters))
        if characters in self._characters_regexes:
            characters_regex = self._characters_regexes[characters]
        else:
            characters_regex = re.compile("[%s]" % re.escape(characters))
            self._characters_regexes[characters] = characters_regex

        return characters_regex.sub(replacement, text)