import re


def build_pattern(placeholder_marker_left: str, placeholder_marker_right: str) -> re.Pattern[str]:
    """
    Creates the pattern used to match the placeholders.
    :param placeholder_marker_left: Marks the beginning of placeholders - internally
    is escaped with re.escape
    :param placeholder_marker_right: Marks the ending of placeholders - internally
    is escaped with re.escape
    :return: Created pattern, that matches the placeholders as specified and optionally
    surrounding quotes with the following groups:
        # group 'prefix_quote': optional leading quote
        # group 'placeholder': everything in between left and right marker (smallest possible
        match only)
        # group 'prefix_quote': optional leading quote
    """
    left_marker = re.escape(placeholder_marker_left)
    right_marker = re.escape(placeholder_marker_right)
    prefix_quote = r'(?P<prefix_quote>"?)'
    suffix_quote = r'(?P<suffix_quote>"?)'
    placeholder = r'(?P<placeholder>.+?)'
    # regex matches everything between left and right marker, optionally in between quotes
    # see https://regex101.com/r/zEwq7N/1
    return re.compile(prefix_quote + left_marker + placeholder + right_marker + suffix_quote)