Created
July 16, 2016 22:39
-
-
Save TwiN/1a95ce10d790a2ba1df0c56b52a2a0ca to your computer and use it in GitHub Desktop.
A python function that gets a substring in a string between two strings.
This file contains hidden or 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 getBetween(s, first, last): | |
try: | |
start = s.index(first ) + len(first) | |
end = s.index(last, start) | |
return s[start:end] | |
except ValueError: | |
return "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment