Skip to content

Instantly share code, notes, and snippets.

@TwiN
Created July 16, 2016 22:39
Show Gist options
  • Save TwiN/1a95ce10d790a2ba1df0c56b52a2a0ca to your computer and use it in GitHub Desktop.
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.
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