import re s = "These are the words in a sentence" regex = re.compile('words|are|in|a|e') print([(re.findall(regex,s)[i], m.start(0)) for i,m in enumerate(re.finditer(regex,s))])
Standard input is empty
[('e', 2), ('e', 4), ('are', 6), ('e', 12), ('words', 14), ('in', 20), ('a', 23), ('e', 26), ('e', 29), ('e', 32)]