import re


def is_desired_header(hline_1, hline_2, desired_level):
    """
    Analyzes line1 and line2 and desired_level (an integer) to determine if the
    two lines represent an interesting level (i.e. match desired_level).

    If true, returns the heading title as a string. If false, returns an empty
    string.
    """
    # If hline_1 starts with a '#' character, we try to extract a title from
    # it.
    match_obj = re.search("^#{%s}[\\s]+(.*)" % desired_level, hline_1.rstrip())
    if match_obj:
        return match_obj.group(1)

    # If desired level is 1 or 2, we need to do a lookahead since these can be:
    #
    #   heading 1
    #   =========
    #
    #      or
    #
    #   heading 2
    #   =========
    #

    level_indicator = "="
    if int(desired_level) == 2:
        level_indicator = "-"

    match_obj = re.search("^[%s]+$" % level_indicator, hline_2.rstrip())
    if match_obj:
        return hline_1.rstrip()

    return ""