import re


def get_hostname_port_database_from_url(content, hostname_regex, port_regex, database_regex):
    """
    Gets hostname, port, and database factors from a jdbc db2 url
    Accepts: content to scan, regexes to capture hostname, port, and database
    Returns: list of tuples of format (hostname, port, database),
             or empty list if no matches
    """
    regex = re.compile(
        r'jdbc:db2:\/\/{hostname}:{port}\/{database}'.format(
            hostname=hostname_regex,
            port=port_regex,
            database=database_regex,
        ),
    )

    return [
        (match[0], match[1], match[2])
        for line in content.splitlines()
        for match in regex.findall(line)
    ]