Skip to content

Instantly share code, notes, and snippets.

@neerajvashistha
Created July 9, 2021 10:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neerajvashistha/8b67b13cb43ab9fed2bb9c881adab3bd to your computer and use it in GitHub Desktop.
Save neerajvashistha/8b67b13cb43ab9fed2bb9c881adab3bd to your computer and use it in GitHub Desktop.
def find_next_index(a_string:str, substring:str)->list:
"""
return find all index of a substring in a_string in a list
"""
raw_substring = r'\b{0}\b'.format(substring)
matches = re.finditer(raw_substring, a_string)
matches_positions = [match.start() for match in matches]
return matches_positions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment