fork download
  1. # your code goes here
  2. import re
  3.  
  4. string = "A B C D"
  5. keys = ["A", "B", "A B"]
  6.  
  7. matches = []
  8. for k in keys:
  9. matches += re.findall(re.escape(k), string)
  10.  
  11. print(matches)
  12.  
Success #stdin #stdout 0.03s 9628KB
stdin
Standard input is empty
stdout
['A', 'B', 'A B']