import re


def replacePatternsAsPerDictionary(input_string, patterns_dictionary):
    """
    Replaces patterns in an inputted string according to the key:value combinations in a dictionary. Useful for replacing
    long name segments such as "_-_" with "-" in instance names during their creation.

    Args:
        input_string (str): String to be processed
        patterns_dictionary(dict): A dictionary that contains the key:value combinations to be used in replacement.
             Keys in the patterns dictionary should be target patterns, while values of the dictionary should be
             the desired replacement patterns or characters.

    Returns:
        A string

    Examples:
        >>> patterns_dictionary = {"_-_" : "-",
        ...                        ": "  : "-" }
        >>> target_string = "Case_1_-_12:_Unknown"
        >>> formatted_string = replacePatternsAsPerDictionary(target_string, patterns_dictionary)
        >>> print(formatted_string)
        Case_1-12:_Unknown
    """

    output_string = input_string

    # replace undesired characters with the desired ones (e.g., ':' -> '-') using dictionary_of_patterns_to_replace
    for each_target_pattern, each_replacement_pattern in patterns_dictionary.items():
        output_string = re.sub(each_target_pattern, each_replacement_pattern, output_string)

    return output_string