Skip to content

Instantly share code, notes, and snippets.

@capsulecorplab
Last active April 4, 2018 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save capsulecorplab/89ef07277555d605badcc8faa62ea4dd to your computer and use it in GitHub Desktop.
Save capsulecorplab/89ef07277555d605badcc8faa62ea4dd to your computer and use it in GitHub Desktop.
Examines a string argument, `dump`, and Extracts all substring elements sandwiched between the given `front` and `back` criteria, and puts them in a list
def undecorate(dump,front,back):
""" dump: string containing desired substring elements
front: string element preceding desired substring element
back: string element following desired substring element
"""
output = []
while front in dump:
start = dump.find(front) + len(front)
end = dump.find(back, start)
if end > 0:
output.append(dump[start:end])
dump = dump[end:len(dump)]
else:
break
return output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment