import re


def _is_reserved_ip(ip):
    """
    Simple test to detect if an IP is private or loopback. Does not check
    validity of the address.
    """

    grp = re.match(r'127.\d{1,3}.\d{1,3}.\d{1,3}', ip) # 127.0.0.0/8
    if grp:
        return True
    grp = re.match(r'10.\d{1,3}.\d{1,3}.\d{1,3}', ip) # 10.0.0.0/8
    if grp:
        return True
    grp = re.match(r'192.168.\d{1,3}.\d{1,3}', ip) # 192.168.0.0/16
    if grp:
        return True
    grp = re.match(r'172.(1[6-9]|2[0-9]|3[0-1]).\d{1,3}.\d{1,3}', ip) # 172.16.0.0/12
    if grp:
        return True
    # No matches
    return False