def mx_match(mx_domains, match_domains):
 match_domains = [(d.replace('.', '[.]').replace('*', '.*') + '$') for d in match_domains]
 for mx_domain in mx_domains:
  if (mx_domain[(-1)] == '.'):
   mx_domain = mx_domain[:(-1)]
  def match_filter(x):
   return re.match(x, mx_domain)
  if any((match_filter(m) for m in match_domains)):
   return True
 return False

def mx_match ( mx_domains , match_domains ) : match_domains = [ ( d . replace ( '.' , '[.]' ) . replace ( '*' , '.*' ) + '$' ) for d in match_domains ] for mx_domain in mx_domains : if ( mx_domain [ ( - 1 ) ] == '.' ) : mx_domain = mx_domain [ : ( - 1 ) ] def match_filter ( x ) : return re . match ( x , mx_domain ) if any ( ( match_filter ( m ) for m in match_domains ) ) : return True return False
return true if any of the mx_domains matches an mx_domain in match_domains .