from typing import Collection
import re


def get_profile_names(profiles: Collection[str]) -> Collection[str]:
    """Extracts names from profile HMMs using regular expressions."""
    names = []
    pattern = re.compile(r"^NAME\s+?(?P<name>\w.+?)$", re.M)
    for profile in profiles:
        matches = [match.group("name") for match in pattern.finditer(profile)]
        names.extend(matches)
    return names