Extend prompt with flexible mode handling regexp.

def make_dynamic_prompt(self, prompt):
        """Extend prompt with flexible mode handling regexp."""
        patterns = ["[\r\n]" + pattern_manager.pattern(
            self.platform, pattern_name, compiled=False) for pattern_name in self.target_prompt_components]

        patterns_re = "|".join(patterns).format(hostname=re.escape(prompt))

        try:
            prompt_re = re.compile(patterns_re)
        except re.error as e:  # pylint: disable=invalid-name
            raise RuntimeError("Pattern compile error: {} ({}:{})".format(e.message, self.platform, patterns_re))

        self.log("Dynamic prompt: '{}'".format(repr(prompt_re.pattern)))
        return prompt_re