def _matchFriends(tg, friends):
 mfilter = (lambda s: len(''.join(re.findall(re.sub('[\\.\\,\\-\\_]', '', '|'.join(tg.split()).lower()), re.sub('[\\.\\,\\-\\_]', '', ' '.join(filter(None, s)).lower())))))
 return sorted(filter((lambda s: (mfilter(s) > 0)), friends), key=mfilter, reverse=True)

def _matchFriends ( tg , friends ) : mfilter = ( lambda s : len ( '' . join ( re . findall ( re . sub ( '[\\.\\,\\-\\_]' , '' , '|' . join ( tg . split ( ) ) . lower ( ) ) , re . sub ( '[\\.\\,\\-\\_]' , '' , ' ' . join ( filter ( None , s ) ) . lower ( ) ) ) ) ) ) return sorted ( filter ( ( lambda s : ( mfilter ( s ) > 0 ) ) , friends ) , key = mfilter , reverse = True )
finds matching friends to a query .