def replace_match(text: str, match: re.Match, old: str, new: str) -> str:
    """Replace occurrences of a substring within a matched section of a given
    text.

    Args:
        text (str): The input text in which replacements will be made.
        match (re.Match): A regex match object representing the section of text to modify.
        old (str): The substring to be replaced.
        new (str): The substring to replace `old` with.

    Returns:
        str: The modified text with the specified replacements made within the matched section.

    """
    start = match.start()
    end = match.end()
    replacement = text[start:end].replace(old, new)
    text = text[:start] + replacement + text[end:]
    return text
Replace occurrences of a substring within a matched section of a given
    text.

    Args:
        text (str): The input text in which replacements will be made.
        match (re.Match): A regex match object representing the section of text to modify.
        old (str): The substring to be replaced.
        new (str): The substring to replace `old` with.

    Returns:
        str: The modified text with the specified replacements made within the matched section.

    
src/pipecat/utils/string.py