Skip to content

Instantly share code, notes, and snippets.

@CodyKochmann
Created May 14, 2015 17:10
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 CodyKochmann/2e8f3aa885935ea58633 to your computer and use it in GitHub Desktop.
Save CodyKochmann/2e8f3aa885935ea58633 to your computer and use it in GitHub Desktop.
searches a string for a substring and returns an array of indexes
def findall(search_field,search):
# searches a string for a substring and returns an array of indexes
# by: Cody Kochmann
tmp_field = search_field.split(search)
if len(tmp_field) == 1:
return(False)
output = []
tmp_string = ""
for i in range(len(tmp_field)):
tmp_string += tmp_field.pop(0)
output.append(len(tmp_string)+(len(search)*i))
output.pop(-1)
return(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment