fork download
  1. import re
  2. strs = ["(a) first, (b) second, (c) important", "(a) aa, (b) cc, (c) dd, (d) oi, (e) important", "(a) aa, (b) asdf, (c) wer" ]
  3. r = re.compile(r'\([a-z]\)\s+([a-z]+)(?=(?:\s*,\s*\([a-z]\)\s+[a-z]+)*\s*,\s*\([a-z]\)\s+important)')
  4. for s in strs:
  5. print(r.findall(s))
  6.  
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
['first', 'second']
['aa', 'cc', 'dd', 'oi']
[]