# parser.py

def parse_region_id(hostgroups: str | None) -> str:
    if not hostgroups:
        return "0"

    if hostgroups == "p00rtmis":
        return "0"

    parts = hostgroups.split("_")
    if len(parts) >= 2:
        return parts[1]

    return "0"
