def mask_matches(nick, mask):
 nick = strings.lower(nick)
 mask = strings.lower(mask)
 mask = mask.replace('\\', '\\\\')
 for ch in '.$|[](){}+':
  mask = mask.replace(ch, ('\\' + ch))
 mask = mask.replace('?', '.')
 mask = mask.replace('*', '.*')
 r = re.compile(mask, re.IGNORECASE)
 return r.match(nick)

def mask_matches ( nick , mask ) : nick = strings . lower ( nick ) mask = strings . lower ( mask ) mask = mask . replace ( '\\' , '\\\\' ) for ch in '.$|[](){}+' : mask = mask . replace ( ch , ( '\\' + ch ) ) mask = mask . replace ( '?' , '.' ) mask = mask . replace ( '*' , '.*' ) r = re . compile ( mask , re . IGNORECASE ) return r . match ( nick )
check if a nick matches a mask .