from typing import Iterable
from typing import Tuple
from typing import Pattern
from typing import Optional


def pattern_match(string: str, patterns: Iterable[Tuple[Pattern[str], str]]) -> Optional[str]:
    """
    Returns the replacement string when a pattern matches the string query

    :param string: string to search for
    :param patterns: iterable of (regex patterns, replacement string) tuples
    :return: replacement string of the fist pattern that matches, None if there's no match
    """
    for pattern, replacement_str in patterns:
        if pattern.match(string):
            return replacement_str