from typing import Union
import re


def extract_id_from_message(content: str) -> Union[int, None]:
    """
    Scans string to extract user/guild/message id\n
    Can extract IDs from mentions or plaintext
    :return: extracted id
    """
    # matching string that has 18 digits surrounded by non-digits or start/end of string
    match = re.match(r'(\D+|^)(\d{18})(\D+|$)', content)

    return int(match.group(2)) if match else None