fork(5) download
  1. import re
  2.  
  3. regex = r"\[[^][]*]|\b(hello)\b"
  4.  
  5. test_str = ("hello world [hello hello] world hello [world hello world hello] world hello [hello] hello")
  6.  
  7. print(list(filter(None, re.findall(regex, test_str))))
Success #stdin #stdout 0.02s 9584KB
stdin
Standard input is empty
stdout
['hello', 'hello', 'hello', 'hello']