Last active
April 4, 2018 21:52
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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