From anonymous, 6 Years ago, written in Python.
This paste is a reply to Untitled from anonymous
- view diff
Embed
  1.  
  2. result = []
  3. terms = ['term1','term2','term3','term4']
  4. text = 'term1 :value1term2 :value2term3 :term4 :value4'
  5. for (i, term) in enumerate(terms):
  6.     # Strip everything before current terminal
  7.     t = text.split(term)[1]
  8.     """
  9.    if i == 0:
  10.        t = text.lstrip(term)
  11.    else:
  12.        t = text.split(term)[1]
  13.    """
  14.     # Strip the next terminal and everything after it
  15.     if i != len(terms)-1:
  16.         t = t.split(terms[i+1])[0]
  17.     t = t.lstrip(" :")
  18.     result.append(t)
  19. print(result)
  20.