def compile_matcher(regex):
 if (not regex):
  return (lambda x: True)
 elif (regex == '!'):
  return (lambda x: False)
 elif regex.startswith('!'):
  rx = re.compile(regex[1:])
  return (lambda x: (rx.search(x) is None))
 else:
  rx = re.compile(regex)
  return (lambda x: (rx.search(x) is not None))

def compile_matcher ( regex ) : if ( not regex ) : return ( lambda x : True ) elif ( regex == '!' ) : return ( lambda x : False ) elif regex . startswith ( '!' ) : rx = re . compile ( regex [ 1 : ] ) return ( lambda x : ( rx . search ( x ) is None ) ) else : rx = re . compile ( regex ) return ( lambda x : ( rx . search ( x ) is not None ) )
returns a function that takes one argument and returns true or false .