You are viewing a single comment's thread. Return to all comments →
import re
S = input() k = input()
pattern = re.compile(f'(?={re.escape(k)})') matches = list(pattern.finditer(S))
if matches: for m in matches: print((m.start(), m.start() + len(k) - 1)) else: print((-1, -1))
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 →
import re
S = input() k = input()
pattern = re.compile(f'(?={re.escape(k)})') matches = list(pattern.finditer(S))
if matches: for m in matches: print((m.start(), m.start() + len(k) - 1)) else: print((-1, -1))