def set_match_strings(matchDict, value):
 for key in matchDict:
  v = matchDict[key]
  if (not isinstance(v, str)):
   continue
  l = len(value)
  if (v[:l].lower() == value):
   matchDict['match_type'] = key
   matchDict['match_string'] = v[:l]
   next_string = v[l:]
   if next_string:
    matchDict['next_string'] = next_string
   break
  elif ((key == 'addr') and (value in v.lower())):
   matchDict['match_type'] = key
   (pre_string, next_string) = v.lower().split(value, 1)
   if pre_string:
    matchDict['pre_string'] = v[:len(pre_string)]
   if next_string:
    matchDict['next_string'] = v[(len(pre_string) + l):]
   matchDict['match_string'] = v[len(pre_string):][:l]
   break

def set_match_strings ( matchDict , value ) : for key in matchDict : v = matchDict [ key ] if ( not isinstance ( v , str ) ) : continue l = len ( value ) if ( v [ : l ] . lower ( ) == value ) : matchDict [ 'match_type' ] = key matchDict [ 'match_string' ] = v [ : l ] next_string = v [ l : ] if next_string : matchDict [ 'next_string' ] = next_string break elif ( ( key == 'addr' ) and ( value in v . lower ( ) ) ) : matchDict [ 'match_type' ] = key ( pre_string , next_string ) = v . lower ( ) . split ( value , 1 ) if pre_string : matchDict [ 'pre_string' ] = v [ : len ( pre_string ) ] if next_string : matchDict [ 'next_string' ] = v [ ( len ( pre_string ) + l ) : ] matchDict [ 'match_string' ] = v [ len ( pre_string ) : ] [ : l ] break
helper method for site_search_ac and org_search_ac find which field the search term matched & where .