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.         if i == 0:
  7.                 t = text.lstrip(term)
  8.         else:
  9.                 t = text.split(term)[1]
  10.         # Strip the next terminal and everything after it
  11.         if i != len(terms)-1:
  12.                 t = t.split(terms[i+1])[0]
  13.         t = t.lstrip(" :")
  14.         result.append(t)
  15. print(result)
  16.  

Replies to Untitled rss

Title Name Language When
Re: Untitled anonymous python 6 Years ago.