def _multireplace(self, string, replacements):
        """
        Given a string and a replacement map, it returns the replaced string.
        Source = https://gist.github.com/bgusach/a967e0587d6e01e889fd1d776c5f3729
        Reference = https://stackoverflow.com/questions/6116978/how-to-replace-multiple-substrings-of-a-string  # noqa
        :param str string: string to execute replacements on
        :param dict replacements: replacement dictionary {value to find: value to replace}
        :rtype: str
        """
        # Place longer ones first to keep shorter substrings from matching where
        # the longer ones should take place
        # For instance given the replacements {'ab': 'AB', 'abc': 'ABC'} against
        # the string 'hey abc', it should produce 'hey ABC' and not 'hey ABc'
        substrs = sorted(replacements, key=len, reverse=True)

        # Create a big OR regex that matches any of the substrings to replace
        regexp = re.compile("|".join([re.escape(s) for s in substrs]))

        # For each match, look up the new string in the replacements
        return regexp.sub(lambda match: replacements[match.group(0)], string)

        Given a string and a replacement map, it returns the replaced string.
        Source = https://gist.github.com/bgusach/a967e0587d6e01e889fd1d776c5f3729
        Reference = https://stackoverflow.com/questions/6116978/how-to-replace-multiple-substrings-of-a-string  # noqa
        :param str string: string to execute replacements on
        :param dict replacements: replacement dictionary {value to find: value to replace}
        :rtype: str
        
contrib/runners/winrm_runner/winrm_runner/winrm_base.py