From anonymous, 6 Years ago, written in Python.
Embed
  1. result = []
  2. terms = ['term1','term2','term3','term4']
  3. text = 'term1 :value1term2 :value2term3 :term4 :value4'
  4. for (i, term) in enumerate(terms):
  5.     # Strip everything before current terminal
  6.     t = text.split(term)[1]
  7.     # Strip the next terminal and everything after it
  8.     if i != len(terms)-1:
  9.         t = t.split(terms[i+1])[0]
  10.     t = t.lstrip(" :")
  11.     result.append(t)
  12. print(result)