0
can i have example for re.finditer ?
2 Respostas
0
import re
pattern = re.compile(r'in',re.M)
example = "an example matching any 'in' herein!"
for item in re.finditer(pattern,example):
print('match object data:',item,' the text matched:',item.group())
0
import re
text="i love python so much. The most beloved people in the world are the spontaneous"
for m in re.finditer(r"\w+ve", text):
print m.group(0)
output:
love
belove