index of regex python code example
Example 1: regex find a word index of all matches
import re
sentence = input("Give me a sentence ")
word = input("What word would you like to find ")
for match in re.finditer(word, sentence):
print (match.start(), match.end())
Example 2: py string find regex pos
import re
re.search('o{3}', 'Python is slooow!').start() # 12