fork(1) download
  1. import re
  2.  
  3. def all_matching(str, rxs):
  4. res = True
  5. for rx in rxs:
  6. p = re.compile(rx, re.M)
  7. res = res and p.search(str)
  8. return(res)
  9.  
  10. input1 = """DIR1\\FILE1.EXT1\tCONTENT11
  11. DIR1\\FILE1.EXT1\tCONTENT12
  12. DIR1\\FILE1.EXT1\tCONTENT13
  13. DIR1\\FILE2.EXT1\tCONTENT21
  14. DIR2\\FILE3.EXT2\tCONTENT31
  15. DIR3\\FILE3.EXT2\tCONTENT11"""
  16.  
  17. input2 = """DIR1\\FILE1.EXT1\tCONTENT11
  18. DIR1\\FILE1.EXT1\tCONTENT12
  19. DIR1\\FILE1.EXT1\tCONTENT13
  20. DIR1\\FILE2.EXT1\tCONTENT21
  21. DIR2\\FILE3.EXT2\tCONTENT31"""
  22.  
  23. rxs = [r"^\S*FILE1\S*\tCONTENT11$",r"^\S*FILE1\S*\tCONTENT12$",r"^\S*FILE3\S*\tCONTENT11$"]
  24.  
  25. if all_matching(input1,rxs):
  26. print("input1 matches all rxs") # excpected
  27. else:
  28. print("input1 do not match all rxs")
  29.  
  30. if all_matching(input2,rxs):
  31. print("input2 matches all rxs")
  32. else:
  33. print("input2 do not match all rxs") # expected because input2 doesn't match wirh rxs[2]
Success #stdin #stdout 0.02s 9440KB
stdin
Standard input is empty
stdout
input1 matches all rxs
input2 do not match all rxs