fork(1) download
  1. import re
  2. test = ['bbb', 'ccc', 'axx', 'xzz', 'xaa']
  3. reg = re.compile(r'^x')
  4. print( list(filter(reg.search, test)) ) # Create iterator using filter, cast to list
  5. # => ['xzz', 'xaa']
  6. print( list(filter(lambda x: not reg.search(x), test)) )
  7. # => ['bbb', 'ccc', 'axx']
Success #stdin #stdout 0.02s 9476KB
stdin
Standard input is empty
stdout
['xzz', 'xaa']
['bbb', 'ccc', 'axx']