Skip to content

Commit 7c54af1

Browse files
solves re start and re end
1 parent 3260ede commit 7c54af1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

regex-and-parsing/re-start-end.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# https://www.hackerrank.com/challenges/re-start-re-end/problem
2+
3+
import re
4+
5+
6+
line = input()
7+
substring = input()
8+
pattern = re.compile(substring)
9+
10+
match = pattern.search(line)
11+
if match is None:
12+
print((-1, -1))
13+
14+
while match:
15+
print('({}, {})'.format(match.start(), match.end()))
16+
match = pattern.search(line, match.start() + 1)

0 commit comments

Comments
 (0)