programming-examples/python/Regular_Expression/Find all adverbs and their positions in a given sentence.py

4 lines
169 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
import re
text = "Clearly, he has no excuse for such behavior."
for m in re.finditer(r"\w+ly", text):
print('%d-%d: %s' % (m.start(), m.end(), m.group(0)))