We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Don't understand how people got finditer() to search for overlapping pattenrs.
I went with a while loop instead:
if __name__ == '__main__':
S = input()
k = input()
pattern = re.compile(k)
i = 0
while i < len(S) - 1:
match = pattern.search(S,i)
if match:
print((match.start(), match.end() - 1 ))
i = match.start() + 1
else:
if i == 0:
print((-1,-1))
break
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Re.start() & Re.end()
You are viewing a single comment's thread. Return to all comments →
Don't understand how people got finditer() to search for overlapping pattenrs. I went with a while loop instead: