import re


def extract_airlines_from_flight_text(flight_text):
    """

    :param flight_text: Raw flight text string, e.g.,
        "3:45 PM – 8:15 PM+1\nUnited\n13h 30m\nSFO–PVG\nNonstop\n$4,823",
        "12:51 PM – 4:50 PM+1\nDelta\nChina Southern\n12h 59m\nSEA–PVG\nNonstop\n$4,197",
        "2:10 AM – 1:25 PM+1\nSeparate tickets booked together\nEVA Air, Spring\n20h 15m\nSEA–PVG\n1 stop\n6h 15m TPE\n$1,194"
    :return: A list of airlines, e.g., ["United"], ["Delta", "China Southern"], ["EVA Air", "Spring"]
    """
    airlines = []
    # We escape flight_text.split("\n")[0] which indicates flight time range.
    for airline_candidate in flight_text.split("\n")[1:]:
        if airline_candidate == "Separate tickets booked together":
            continue
        if re.match(r"(\d+h )?\d+m", airline_candidate):
            # The flight time length indicates the end of airline info.
            break
        airlines.extend(airline_candidate.split(","))
    return airlines