fork download
  1. import re
  2. texts = ["Mark Samson: CA", "Sam Smith: US", "Dawn Watterton: CA", "Neil Shughar: CA", "Fennial Fontaine: US"]
  3. for text in texts:
  4. match = re.search(r".+?(?=:\s*US$)", text)
  5. if match:
  6. print(match.group())
Success #stdin #stdout 0.03s 9512KB
stdin
Standard input is empty
stdout
Sam Smith
Fennial Fontaine