Created
May 14, 2015 17:10
-
-
Save CodyKochmann/2e8f3aa885935ea58633 to your computer and use it in GitHub Desktop.
searches a string for a substring and returns an array of indexes
This file contains 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 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