(expr, lines)
Must be only one match, otherwise result is None.
    When there is a match, strip leading "[" and trailing "]"
Must be only one match, otherwise result is None.
    When there is a match, strip leading "[" and trailing "]"
Must be only one match otherwise result is None . When there is a match strip leading [ and trailing ]
def get_one_match(expr, lines):
    """
    Must be only one match, otherwise result is None.
    When there is a match, strip leading "[" and trailing "]"
    """
    # member names in the ld_headers output are between square brackets
    expr = rf'\[({expr})\]'
    matches = list(filter(None, (re.search(expr, line) for line in lines)))
    if len(matches) == 1:
        return matches[0].group(1)
    else:
        return None
def get_one_match ( expr , lines ) : # member names in the ld_headers output are between square brackets expr = rf'\[({expr})\]' matches = list ( filter ( None , ( re . search ( expr , line ) for line in lines ) ) ) if len ( matches ) == 1 : return matches [ 0 ] . group ( 1 ) else : return None