def search_reverse(prog, chars, col):
 m = prog.search(chars)
 if (not m):
  return None
 found = None
 (i, j) = m.span()
 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 ( ) 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
search backwards and return an re match object or none .