P22019 [HackerRank] Re start re end
普及-
题目描述

start() & end()

These expressions return the indices of the start and end of the substring matched by the group.

Code

import re
m = re.search(r'$\d+$','1234')
m.end()
4
m.start()
0

Task

You are given a string $\mbox{S}$.

Your task is to find the indices of the start and end of string $\boldsymbol{k}$ in $\mbox{S}$.

Input Format

The first line contains the string $\mbox{S}$.

The second line contains the string $\boldsymbol{k}$.

Constraints

$0<len(S)<100$

$0<len(k)<len(S)$

Output Format

Print the tuple in this format: (start _index, end _index).

If no match is found, print (-1, -1).

Sample Input
aaadaa
aa

Sample Output
(0, 1)
(1, 2)
(4, 5)

输入格式

见题面

输出格式

见题面

样例输入
aaadaa aa
样例输出
(0, 1) (1, 2) (4, 5)