from typing import Union
import re


def get_by_regex(regex, content: str) -> Union[str, None]:
    """Matches content by regex and returns the value captured by the first group, or None if there was no match

    :param regex: A compiled regex to match
    :type regex: re.Pattern
    :param content: The content on which the regex should be applied
    :type content: str
    :rtype: str, None
    """
    match = re.search(regex, content)
    return match.group(1).strip() if match else None