(prog, chars, col)
return found
Search backwards and return an re match object or None.

    This is done by searching forwards until there is no match.
    Prog: compiled re object with a search method returning a match.
    Chars: line of text, without \\n.
    Col: stop index for the search; the limit for match.end().
Search backwards and return an re match object or None.
Search backwards and return an re match object or None .
def search_reverse(prog, chars, col):
    '''Search backwards and return an re match object or None.

    This is done by searching forwards until there is no match.
    Prog: compiled re object with a search method returning a match.
    Chars: line of text, without \\n.
    Col: stop index for the search; the limit for match.end().
    '''
    m = prog.search(chars)
    if not m:
        return None
    found = None
    i, j = m.span()  # m.start(), m.end() == match slice indexes
    while i < col and j <= col:
        found = m
        if i == j:
            j = j+1
        m = prog.search(chars, j)
        if not m:
            break
        i, j = m.span()
    return found
def search_reverse ( prog , chars , col ) : m = prog . search ( chars ) if not m : return None found = None i , j = m . span ( ) # m.start(), m.end() == match slice indexes while i < col and j <= col : found = m if i == j : j = j + 1 m = prog . search ( chars , j ) if not m : break i , j = m . span ( ) return found