import re


def is_header(line, max_level):
    """if max_level is 0 assumes all headers ok

    Examples
    --------
    >>> is_header("abc",0)
    False
    >>> is_header("#",0)
    False
    >>> is_header("# title",0)
    True
    >>> is_header("### title",3)
    True
    >>> is_header("### title",2)
    False

    """
    if max_level:
        return len(re.findall('^#{{1,{0}}} .+'.format(max_level), line)) > 0
    else:
        return len(re.findall('^#+ .+', line)) > 0