Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
7 lines (5 sloc) 187 Bytes
def substring(haystack, needle, n):
parts= haystack.split(needle, n+1)
if len(parts)<=n+1:
return haystack
return haystack[:len(haystack)-len(parts[-1])-len(needle)]