import re


def underlined_part(s, underline_char='^'):
    """Return the part of `s` that is underlined.

    Given a multiline string, return the part of the first line that has
    underline_char on the second line.
    """
    lines = s.splitlines()
    underline_re = re.compile(re.escape(underline_char) + '+')
    m = underline_re.search(lines[1])
    if not m:
        raise ValueError("String %r has no underline" % (s,))
    return lines[0][m.start():m.end()]