fork download
  1. text = '''first_condition(enabled)
  2. extra_condition(disabled)
  3. testing(example)
  4. other(something)'''
  5.  
  6. import re
  7.  
  8. d = dict(re.findall(r'^(.*)\((.*)\)$', text, re.M))
  9. keys = ['first_condition', 'extra_condition', 'testing', 'other']
  10. result = [d.get(key, '') for key in keys]
  11. print result
Success #stdin #stdout 0.02s 4676KB
stdin
Standard input is empty
stdout
['enabled', 'disabled', 'example', 'something']