fork download
  1. import re
  2. file=r'''14:00:01 type1 "xyz" has no relationships... ಠ_ಠ
  3. 14:00:01 type2 "xyza" has no relationships... ಠ_ಠ
  4. 14:00:01 type2 "aaaa" has no relationships... ಠ_ಠ
  5. 14:00:01 type3 "asdg" has no relationships... ಠ_ಠ
  6. 14:00:01 type4 "dhj" has no relationships... ಠ_ಠ'''
  7. matches = []
  8. rx = re.compile(r'(\w+) "([^"]*)"')
  9. for line in file.splitlines():
  10. m = rx.search(line)
  11. if m:
  12. matches.append(f'{m.group(1)} {m.group(2)}')
  13.  
  14. print(matches)
Success #stdin #stdout 0.03s 9436KB
stdin
Standard input is empty
stdout
['type1 xyz', 'type2 xyza', 'type2 aaaa', 'type3 asdg', 'type4 dhj']