Skip to content

Instantly share code, notes, and snippets.

@erochest
Created August 4, 2016 13:11
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 erochest/88677a2e8ed439eb9bb0c4757f2de99b to your computer and use it in GitHub Desktop.
Save erochest/88677a2e8ed439eb9bb0c4757f2de99b to your computer and use it in GitHub Desktop.
def findall(haystack, needle):
i = 0
while True:
j = haystack.find(needle, i)
if j is -1:
break
yield j
i = j + 1
list(findall('abcadeaafghijak', 'a'))
# [0, 3, 6, 7, 13]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment