import re


def _extract_names_by(code: str, /, *, pattern: re.Pattern[str]) -> list[str]:
    """``function``

    Extracting any names from python file by regex.

    code: :class:`str` [Positional-only]
        Some python code.

    pattern: :class:`re.Pattern` [Keyword-only]
        The pattern by which the names will be extracted.
    """
    matches: list[str] = []
    for match in pattern.findall(code):
        matches.append(match)

    return matches