def match_endofsentence(text: str) -> int:
    """Finds the position of the end of a sentence in the provided text string.

    This function processes the input text by replacing periods in email
    addresses and numbers with ampersands to prevent them from being
    misidentified as sentence terminals. It then searches for the end of a
    sentence using a specified regex pattern.

    Args:
        text (str): The input text in which to find the end of the sentence.

    Returns:
        int: The position of the end of the sentence if found, otherwise 0.

    """
    text = text.rstrip()

    # Replace email dots by ampersands so we can find the end of sentence. For
    # example, first.last@email.com becomes first&last@email&com.
    emails = list(EMAIL_PATTERN.finditer(text))
    for email_match in emails:
        text = replace_match(text, email_match, ".", "&")

    # Replace number dots by ampersands so we can find the end of sentence.
    numbers = list(NUMBER_PATTERN.finditer(text))
    for number_match in numbers:
        text = replace_match(text, number_match, ".", "&")

    # Match against the new text.
    match = ENDOFSENTENCE_PATTERN.search(text)

    return match.end() if match else 0
Finds the position of the end of a sentence in the provided text string.

    This function processes the input text by replacing periods in email
    addresses and numbers with ampersands to prevent them from being
    misidentified as sentence terminals. It then searches for the end of a
    sentence using a specified regex pattern.

    Args:
        text (str): The input text in which to find the end of the sentence.

    Returns:
        int: The position of the end of the sentence if found, otherwise 0.

    
src/pipecat/utils/string.py