import re
string1 = "aaabaa"
zusuchen = "aa"
#1
m_start = re.finditer(fr'(?=({zusuchen}))', string1)
results = [(match.start(1), match.end(1)-1) for match in m_start]
for z in results:
print(z)
print("Now #2:")
#2
m_start = re.finditer(fr'(?={zusuchen})', string1)
results = [(match.start(), match.end()-1) for match in m_start]
for z in results:
print(z)
I still haven’t figured out what’s the problem for the #2.
I thought the Output should be the same
But the Output I got:
(0, 1)
(1, 2)
(4, 5)
Now #2:
(0, -1)
(1, 0)
(4, 3)
New contributor
Hotbread is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.