import re


def check_host(hostname, black_list, white_list):
    """Check hostname to see if it valid

    Checks if the hostname is in the white and black list and return back
    according to the regex filtering.
    """

    for host_regex in black_list:
        if len(host_regex) > 1 and re.search(host_regex, hostname):
            return False

    for host_regex in white_list:
        if re.search(host_regex, hostname):
            return True

    return False