def METHOD_NAME(self, contents: str):
    processor_pattern = re.compile(
        f"{self.REPLACEMENT_TOKEN}(.*?){self.ARGS_TOKEN}(.*?){self.REPLACEMENT_TOKEN}"
    )
    matches = list(processor_pattern.finditer(contents))
    for match in reversed(matches):
        action = match.group(1)
        args = match.group(2).split(self.ARGS_TOKEN)
        if action not in self.allowed_actions:
            raise Exception(f"Replacement action '{action}' is not allowed")
        replacement = getattr(self, action)(*args)
        contents = contents[: match.start(0)] + replacement + contents[match.end(0) :]
    return contents