from typing import Pattern
import re


def remove_duplicate(input_str: str, duplicated_pattern: Pattern, replace: str = "") -> str:
    """Remove a duplicated pattern in a string."""
    while re.search(duplicated_pattern, input_str):
        input_str = re.sub(duplicated_pattern, replace, input_str)
    return input_str